in reply to File:Find::Rule on Win32

Update: Ahhh..did not read your last para prorperly. davidrw's suggestion should do it. If I understand it correctly $_ sets the current short name and not the absolute path so you might want to experiment with that number as the total path limitation could still be an issue...end update

I am not sure what is your file system but Windows has a limitation with the number of chars on the path.

I found this link which talks about how the Win32 API call can be made so that the path will be treated as a unicode. I tried to use it in Perl and did not work.

http://cert.uni-stuttgart.de/archive/bugtraq/2002/01/msg00376.html

I tried to create a deep path on my Windows XP pro. It did not get ver far

#!/usr/bin/perl -w my $path = "/monktemp"; chdir($path) or die "Cannot chdir to /monktemp: ($!)"; for (1..300) { mkdir("monk", 0755) or die "Cannot mkdir monk: $!"; chdir("monk") or die "Cannot chdir to monk: ($!)"; $path .= "/monk"; print ("Done Processing $_ levels: Path length so far =", length($ +path),"\n"); }

Output:

...... ...... Done Processing 45 levels: Path length so far =234 Done Processing 46 levels: Path length so far =239 Done Processing 47 levels: Path length so far =244 Cannot mkdir monk No such file or directory at createdir line 7.
I haven't looked at the Documentation for the exec method yet but not sure whether any non-system method can be made to go deeper than 255 char limitation!

cheers

SK

Replies are listed 'Best First'.
Re^2: File:Find::Rule on Win32
by puploki (Hermit) on Jul 24, 2005 at 20:20 UTC
    Thanks to you both for your suggestions - I've done some experimenting and it seems that the $_ value inside the nested subroutine you can use in File::Find::Rule does contain the full path (so, full directory path + filename). Using the line...
    my @results = File::Find::Rule->file->exec( sub { length($_[1]) < 255 +} )->in( $dir );
    ...does indeed exclude any files with an invalid path length. Incidentally, these appear to have come about because directories are shared out half way down the tree and people have then written deep nested directories & files to it. When I come to analyse the directories from the top, the path length is now longer and over the 255 limit.

    Cheers both!