in reply to Re: Filenames beyond 260 chars in Perl on WinXP
in thread Filenames beyond 260 chars in Perl on WinXP

Thanks for the quick answer.

I will look into that carefully, but that looks (1) a lot of work and (2) like kissing goodbye to portability (I have already small platform specific snippets, but here we seem to be talking of a totally different level of platform specificity).

My naive question is: why Perl port on WinXP does not use natively the "good" routines, etc. and falls victim of these last-century limitations? Especially that you CAN avoid them in WinXP (and some applications do) and the file systems have no such ridiculous limitations.

Thanks!

p.

  • Comment on Re^2: Filenames beyond 260 chars in Perl on WinXP

Replies are listed 'Best First'.
Re^3: Filenames beyond 260 chars in Perl on WinXP
by Corion (Patriarch) on Nov 08, 2009 at 11:55 UTC

    Support for Win9x has just been dropped from Perl, so you might actually see a move to the *W APIs in Perl. Of course, it will move faster if you contribute a patch :).

    The major obstacle in moving towards the *W APIs is that much of the Perl code assumes that filenames are plain ASCII and have no encoding attached, which is obviously not the case with the *W APIs anymore.

Re^3: Filenames beyond 260 chars in Perl on WinXP
by cdarke (Prior) on Nov 08, 2009 at 13:15 UTC
    You are not being very generous. Perl is written in C, and the C standard defines a constant FILENAME_MAX which is set to 260 in the Microsoft header files.

    There is another Microsoft specific constant called MAX_PATH, and to quote the MSDN: "In the Windows API, the maximum length for a path is MAX_PATH, which is defined as 260 characters."

    Exceptions are when using the Unicode interfaces and WCHARS, as you imply, which give a theoretical filename maximum of 32,767 characters. The sting in the tail of using such filenames is that there are several Microsoft APIs that do not support them; quoting the MSDN again: "It is possible to create a path with the Windows API that the shell user interface might not be able to interpret properly.". I don't think it is unreasonable that supporting such filenames has not been a priority.

      My apologies--I did not mean to be ungenerous to Perl, which has helped me solving quite a bit of issues efficiently and elegantly with limited effort, nor to the developers, who make a splendid job. Yet, I use both various forms of Unix (well, lately it is Linux) and WinXP, and I find in the latter some limitations which seem to come right out of the '80s. The 260-char for a pathname is one of them, and probably I am not alone thinking it a bit ridiculous if the API supports "somehow" much longer lengths and the file system absolutely and perfectly does. I would have just found splendid if Perl could circumvent some of these "artificial" limitations, as it seems possible. But I agree--in the big picture it is probably a low priority and my search on the web suggests it is not a very common problem for people.

      To Corion: I'd love to, but I am too incompetent to even try. Even for my own purpose, I guess I will simply have to run the scripts on a Linux box.

      Thanks,

      p.