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

List:       kde-devel
Subject:    Re: An interesting problem: determining filename length
From:       Michael Pyne <mpyne () purinchu ! net>
Date:       2009-01-07 20:07:16
Message-ID: 200901071507.20939.mpyne () purinchu ! net
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/alternative)]


On Wednesday 07 January 2009, Joris Guisson wrote:
> /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.

QFile::encodeName() should be the right direction to go.  However keep in mind 
that the length limit you're talking about is for each element in the path, 
not the entire path (you're referring to NAME_MAX, see below).

For instance, the file name length of /usr/bin/perl would be 4, not 13.

On the other hand, the fully qualified path of a file name cannot exceed 
PATH_MAX characters typically.

Consult http://www.gnu.org/software/libc/manual/html_node/Limits-for-
Files.html#Limits-for-Files for more information.  Specifically it seems to 
call out for pathconf, which is defined in unistd.h.

Regards,
 - Michael Pyne

[Attachment #7 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" \
"http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" \
content="1" /><style type="text/css">p, li { white-space: pre-wrap; \
}</style></head><body style=" font-family:'Consolas'; font-size:11pt; \
font-weight:400; font-style:normal;">On Wednesday 07 January 2009, Joris Guisson \
wrote:<br> &gt; /home/joris/ktorrent/downloads/VIA POUYSHIE SERDCA-Zolotaja \
kollekcija<br> &gt; VIA[LP,CD,EP]/ВИА ПОЮЩИЕ СЕРДЦА-1976-Миньон Г62-05667-8 Песни<br>
&gt; АнатолияДнепрова/02. Лицо в ладонях(А.Днепров-И.Кохановский).mp3<br>
&gt;<br>
&gt; Using QFile::encodeName will result in a length of 273 which is longer<br>
&gt; then the limit on linux (255), however creating the file without<br>
&gt; shortening it, works without any problems. My guess is that the latin<br>
&gt; characters are probably<br>
&gt;<br>
&gt; So does anybody know how you actually determine the length of a such a<br>
&gt; filename ? Preferably in a portable manner, and obviously it must work<br>
&gt; will all posible characters in a filename.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"><br></p>QFile::encodeName() should be the right direction to go.  \
However keep in mind that the length limit you're talking about is for each element \
in the path, not the entire path (you're referring to NAME_MAX, see below).<br> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>For \
instance, the file name length of /usr/bin/perl would be 4, not 13.<br> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>On \
the other hand, the fully qualified path of a file name cannot exceed PATH_MAX \
characters typically.<br> <p style="-qt-paragraph-type:empty; margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;"><br></p>Consult \
http://www.gnu.org/software/libc/manual/html_node/Limits-for-Files.html#Limits-for-Files \
for more information.  Specifically it seems to call out for pathconf, which is \
defined in unistd.h.<br> <p style="-qt-paragraph-type:empty; margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
                text-indent:0px; -qt-user-state:0;"><br></p>Regards,<br>
 - Michael Pyne</p></body></html>


["signature.asc" (application/pgp-signature)]

>> 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