fixed issue if no loading dock
[feisty_meow.git] / scripts / files / filename_helper.pl
index 86de1dab12d1c30d157f1b3419bab9e50d943859..50b71edc7a626675923fc7f6ffcacc9c92830a9c 100644 (file)
@@ -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}$/;