in reply to Filenames beyond 260 chars in Perl on WinXP

To access long paths, you need to use both \\? and the "W" systems interface. None of the native calls use the "W" interface. You'll need to call the system yourself. Win32API::File might help.
  • Comment on Re: Filenames beyond 260 chars in Perl on WinXP

Replies are listed 'Best First'.
Re^2: Filenames beyond 260 chars in Perl on WinXP
by ienne (Novice) on Nov 08, 2009 at 06:07 UTC

    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.

      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.

      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.