[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    An interesting problem: determining filename length
From:       "Joris Guisson" <joris.guisson () gmail ! com>
Date:       2009-01-07 19:29:03
Message-ID: 6bc528f40901071129x5a1ea517xa3bed163dfae029e () mail ! gmail ! com
[Download RAW message or body]

As you might be aware there is a filename length limit on most
operating systems, when you create a file with a longer name you run
into trouble. Seeing that a bittorrent client has no control over the
filenames in a torrent, it can encounter the problem that the
filenames are too long, so obviously it needs to shorten long
filenames. I'm now trying to figure out a way to determine the length
of a filename.

Easy, you would think, however suppose the filename is in a QString,
using QString::length() will give you wrong results, seeing that it
will give you the number of characters and a character may take up
more bytes then one. So my second approach was to use
QFile::encodeName(filename).length(), this also does not work, it
overestimates the length of names containing both latin and cyrillic
characters. For example :

/home/joris/ktorrent/downloads/VIA POUYSHIE SERDCA-Zolotaja kollekcija
VIA[LP,CD,EP]/ВИА ПОЮЩИЕ СЕРДЦА-1976-Миньон Г62-05667-8 Песни
АнатолияДнепрова/02. Лицо в ладонях(А.Днепров-И.Кохановский).mp3

Using QFile::encodeName will result in a length of 273 which is longer
then the limit on linux (255), however creating the file without
shortening it, works without any problems. My guess is that the latin
characters are probably

So does anybody know how you actually determine the length of a such a
filename ? Preferably in a portable manner, and obviously it must work
will all posible characters in a filename.

Joris,
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic