X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Ffiles%2Ffilename_helper.pl;h=50b71edc7a626675923fc7f6ffcacc9c92830a9c;hb=b6a31e0e31b2fa661518b93e9a1801324d41c265;hp=86de1dab12d1c30d157f1b3419bab9e50d943859;hpb=4b55659ba1a25adb598f03b13b10965336186e83;p=feisty_meow.git diff --git a/scripts/files/filename_helper.pl b/scripts/files/filename_helper.pl index 86de1dab..50b71edc 100644 --- a/scripts/files/filename_helper.pl +++ b/scripts/files/filename_helper.pl @@ -408,7 +408,8 @@ return; } local *DIR; - opendir DIR, $dir or die "opendir $dir: $!"; + # if we can't open the dir, just skip to the next one. + opendir DIR, $dir or next; while ($_ = readdir DIR) { next if /^\.{1,2}$/; my $path = "$dir/$_"; @@ -428,7 +429,8 @@ sub find_directories { my $dir; foreach $dir (@_) { local *DIR; - opendir DIR, $dir or die "opendir $dir: $!"; + # if we can't open the dir, just skip to the next one. + opendir DIR, $dir or next; while ($_ = readdir DIR) { # skip if it's current or parent dir. next if /^\.{1,2}$/; @@ -444,13 +446,19 @@ sub find_directories { ############################################################################ -# given a directory, this returns an array of all the filenames found therein. +# given a list of paths, this returns an array of all the filenames found therein. sub find_files { my @files_found = (); my $dir; foreach $dir (@_) { + if (-f $dir) { + # that's actually just a file, so add it. + push @files_found, $dir; + next; + } local *DIR; - opendir DIR, $dir or die "opendir $dir: $!"; + # if we can't open the dir, just skip to the next one. + opendir DIR, $dir or next; while ($_ = readdir DIR) { # skip if it's current or parent dir. next if /^\.{1,2}$/;