Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > File::Find dies on directory paths which are too long

Reply
Thread Tools

File::Find dies on directory paths which are too long

 
 
wbeldman@gmail.com
Guest
Posts: n/a
 
      03-13-2007
I am trying to traverse the file system on a remote computer from a
Windows machine to report on specific extensions. Here is the source
code:
=====================================
#! C:\Perl\bin\perl.exe -w
####
# This program was generated by 'find2perl' and is slightly tweaked to
suit our needs (on Windows).
# usage is: findext.pl directory extension
# eg. findext.pl \\cluster\itshome doc

eval 'exec C:\Perl\bin\perl.exe -S $0 ${1+"$@"}' if 0; #
$running_under_some_shell

use strict;
use File::Find ();

# Set the variable $File::Find::dont_use_nlink if you're using AFS,
# since AFS cheats.

# for the convenience of &wanted calls, including -eval statements:
use vars qw/*name *dir *prune/;
*name = *File::Find::name;
*dir = *File::Find::dir;
*prune = *File::Find:rune;

sub wanted;

if ($#ARGV+1 != 2){
die "Proper usage:\n\t$0 directory ext\n\tdirectory=$ARGV[0] and
extension=$ARGV[1]\n";
}
if (!(-d $ARGV[0])){
die "$ARGV[0] is not a valid directory\n";
}
# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, "$ARGV[0]");
exit;


sub wanted {
#Replace \\cluster.../folder/something.mp3 with \\cluster...\folder
\something.mp3
$name =~ s/\//\\/g;
if (/^.*\.$ARGV[1]\z/s){
print "$name\n";
}
}
=====================================
The program works great except when I run into a directory which is
too long. In windows explorer, I can't CD to a path like \\compname
\sharename\directory\{many subdirectories}\directory because I get:
"Can't access this folder Path too long". When I use the above program
it crashes at that point and I get:
=====================================
Can't opendir(\\compname\sharename\directory\{many subdirectories}
\directory): No such file or directory
at D:\Scripts\dev\Send Reports\MP3 Reports\findext.pl line 30
Can't cd to \\compname\sharename\directory\{many subdirectories}
\directory../.. at C:/Perl/lib/File/Find.pm line 896.
=====================================
My question is, how would I get around this problematic directory and
just let my program continue on to all the other directories in that
share?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Having compilation error: no match for call to ‘(const __gnu_cxx::hash<long long int>) (const long long int&)’ veryhotsausage C++ 1 07-04-2008 05:41 PM
Allow Roles name too long?? AD groups too long? Integrated Security wildman@noclient.net ASP .Net 0 03-10-2008 03:47 PM
Paths, gentleman, paths Ohad Lutzky Ruby 2 11-07-2006 02:15 AM
Perl 'system' Creates Program That Dies When First C Program Dies Christopher M. Lusardi Perl Misc 3 10-19-2003 11:53 AM
Convert between Windows style paths and POSIX style paths Noah Python 5 07-11-2003 09:25 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57