puploki has asked for the wisdom of the Perl Monks concerning the following question:
I'm writing some code to try and make some sense out of a mess of some windows file servers I have inherited. It's coming on quite nicely - I'm essentially trying to determine the size of various directories including all their subdirectories and files. To do this, I'm using File::Find::Rule with the following snippet of code:
The problem came when it tried to navigate a very deep directory: Can't cd to [very long path] at C:/Perl/lib/File/Find.pm line 929. The windows path-length at this point is waaaaay over the 255 character limit.use strict; use File::Find::Rule; my $dir = "c:/temp/test"; my @results = File::Find::Rule->file->in( $dir ); my $totalsize = 0; foreach my $result ( @results ) { $totalsize += (stat($result))[7]; } my $mbtotalsize = $totalsize /1024 / 1024; print "$dir=$mbtotalsize MB\n";
My question (finally!) is this - how can I stop File::Find::(Rule) dying at this point - I just want it to skip over any illegally named files (because of their path length). I could just change the File::Find module to "warn" instead of "die" at that point, but that may have unexpected consquences.
Any advice humbly received!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File:Find::Rule on Win32
by davidrw (Prior) on Jul 24, 2005 at 16:02 UTC | |
|
Re: File:Find::Rule on Win32
by GrandFather (Saint) on Jul 24, 2005 at 20:38 UTC | |
|
Re: File:Find::Rule on Win32
by sk (Curate) on Jul 24, 2005 at 16:22 UTC | |
by puploki (Hermit) on Jul 24, 2005 at 20:20 UTC |