dropping debugging again
[feisty_meow.git] / scripts / files / filename_helper.pl
index 86de1dab12d1c30d157f1b3419bab9e50d943859..3be75c780d307c2a4f2fb9aa01cf6a941a10a354 100644 (file)
@@ -75,7 +75,7 @@ sub glob_list {
       $match =~ s/\*/.*/g;  # replace asterisks with dot star.
       $match =~ s/\+/\\+/g;  # escape plusses.
       $match =~ s/\?/\\?/g;  # escape question marks.
-      $match =~ s/\|/\\?/g;  # escape pipe char.
+      $match =~ s/\|/\\|/g;  # escape pipe char.
       $match =~ s/\$/\\\$/g;  # escape dollar sign.
       $match =~ s/\[/\\[/g;  # escape open bracket.
       $match =~ s/\]/\\]/g;  # escape close bracket.
@@ -89,6 +89,7 @@ sub glob_list {
       if ($possible_name =~ /$match/) {
         # this one matches so add it.
         push @to_return, $chopped_filename[0] . $possible_name;
+#print "a match on: $chopped_filename\n";
       }
     }
   }
@@ -408,7 +409,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 +430,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 +447,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}$/;