morgon has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I have a problem using Archive::Zip on Windows Server 2003.

The problem is that when doing an "addTree" Archive::Zip walks the tree using File::Find which in my case dies in a particular directory because it fails to do chdir ../../../../../../../../../../../..

The interesting thing now is that when I open a cmd.exe-shell and navigate to this directory and try to do a "cd ../../<and so on>" it also fails, so it seems to me I am running into a Windows-specific limitation.

The path-length of the directory where this problem occurs is 225 characters and the length of the ../..-part is 35 characters, so together it is 260...

I have made some experiments and it seems to me that on Windows if you are in a directory and you try to do a "cd <upwards-only>" then that fails if the pathlength of the directory plus the path-length of the upward-path exceeds 260 (or so).

Is that really true?

If that is the case, how would you work around it when using Archive::Zip or File::Find?

Many thanks!

Replies are listed 'Best First'.
Re: File::Find problem on Windows
by ww (Archbishop) on Jan 20, 2012 at 13:51 UTC
      cd \ works.

      Also if I make a parallel directory with a shorter name and go there I can then do the "cd ../../<and-so-on>.

      I am aware that there is a max-lengths for paths, but the funny thing is that the path-length of your current directory seems to limit the levels you can cd up.

Re: File::Find problem on Windows
by lune (Pilgrim) on Jan 20, 2012 at 13:58 UTC
    A quick search for windows maximum path length gives the following link as the first search result: Maximum path length in Windows

    Don't know a way to work around system limitations though ...

    What is worse: You cannot probably determine in advance, whether the path will be too long.

      When you don’t feel like fixing it, document it ...   ;-)

        and call it a feature.

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: File::Find problem on Windows
by raybies (Chaplain) on Jan 20, 2012 at 13:54 UTC
    You sure you did cd ../..? Cuz Windows cmd.exe-shell uses \ (Backslash) as the directory switch indicator, not / (frontslash).
      On Windows both "/" and "\" work as path-delimiters.