X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;ds=inline;f=scripts%2Ffiles%2Ffilename_helper.pl;h=a6632cf512869722e77d81659434f27554a0f4d2;hb=d47e6cd1f5e7d8a855c68ac19271c6673681cffa;hp=9b8668c2f31070f8d1dbdf63ffc5a8ed63944572;hpb=b763a8ff679bbb4112ddf7be8543555183922600;p=feisty_meow.git diff --git a/scripts/files/filename_helper.pl b/scripts/files/filename_helper.pl index 9b8668c2..a6632cf5 100644 --- a/scripts/files/filename_helper.pl +++ b/scripts/files/filename_helper.pl @@ -66,20 +66,26 @@ sub glob_list { local(@files_found) = readdir(WHERE); closedir WHERE; foreach $possible_name (@files_found) { - # zoom through the list and see if we need to add it to the ones - # matching the passed in patterns. -# if ( ($possible_name eq ".") || ($possible_name eq "..") ) { -# # skip the directory entries. -# print "skipping dir entries\n"; -# next; -# } - # we need to process this a bit; directory patterns are different. + # we need to process the pattern a bit; directory patterns are different + # from perl regular expression patterns, so we end up massaging any "ls" + # wildcards into an equivalent perl-style one below. local($match) = $chopped_filename[1]; +#hmmm: would be nice to combine the replacements into a long batch instead of separate commands, but i do not seem to know how to do that yet in perl. $match =~ s/\./\\./g; # replace periods with escaped ones. $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 dollar sign. + $match =~ s/\[/\\[/g; # escape open bracket. + $match =~ s/\]/\\]/g; # escape close bracket. + $match =~ s/\(/\\(/g; # escape open quote. + $match =~ s/\)/\\)/g; # escape close quote. + $match =~ s/\{/\\{/g; # escape open curly bracket. + $match =~ s/\}/\\}/g; # escape close curly bracket. + $match = "^" . $match . "\$"; # make sure the whole thing matches. -#print "possibname is $possible_name\n"; +#print "possibname is '$possible_name':\n"; if ($possible_name =~ /$match/) { # this one matches so add it. push @to_return, $chopped_filename[0] . $possible_name; @@ -333,7 +339,7 @@ sub important_filename { "\\.sbr", ".*scc", "^Setup\\.dbg", "^Setup\\.inx", "^Setup\\.map", "^Setup\\.obs", "^Selenium_.*Login.html", "\\.stackdump", "^string1033\\.txt", "\\.suo", "\\.swp", - "^thumbs.db", "\\.tmp", "^trans\\.tbl", "\\.user", "_version\\.h", + "^thumbs.db", "[a-zA-Z0-9]\\.tmp", "^trans\\.tbl", "\\.user", "_version\\.h", "_version\\.rc", "^waste", "\\.ws4", "\\.wsm"); foreach $temp (@junk_files) { @@ -394,9 +400,16 @@ sub upper { # recursively deletes a directory that is passed as the single parameter. # from http://developer.novell.com/wiki/index.php/Recursive_Directory_Remove sub recursive_delete { + +#hmmm: this should iterate across all params. my $dir = shift; - local *DIR; + if ( -f "$dir" ) { +print "this is not a dir: $dir\nshould whack it here?\n"; +return; + } + + local *DIR; opendir DIR, $dir or die "opendir $dir: $!"; my $found = 0; while ($_ = readdir DIR) {