# version of the License. Please send any updates to "fred@gruntose.com". #
###############################################################################
-require "importenv.pl";
+use Env qw(OS IS_MSYS);
############################################################################
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;
return &canonicalizer(@_, "/");
}
-# similar to the normal unix version, but supports msys's weird paths.
-sub msys_canonicalize {
- return &canonicalizer(@_, "/", 1);
-}
-
-# similar to the msys version, but services cygwin.
-sub cygwin_canonicalize {
- return &canonicalizer(@_, "/", 2);
-}
-
-
# this more general routine gets a directory separator passed in. it then
# replaces all the separators with that one.
-
sub canonicalizer {
local($directory_name) = $_[0];
local($dirsep) = $_[1];
- local($do_funky) = $_[2];
-#print "do funky is set to \"$do_funky\"\n";
#print "old dir name is \"$directory_name\"\n";
if ($OS =~ /win/i) {
#somewhat abbreviated check; only catches windoze systems, not dos or os2.
- if ($do_funky eq "1") {
+ # IS_MSYS is calculated by feisty meow scripts startup; it will be
+ # non-empty if this is the msys tool kit.
+ if (length($IS_MSYS) > 0) {
# msys utilities version (http://www.mingw.org)
$directory_name =~ s/^(.):[\\\/](.*)$/\/\1\/\2/;
- } elsif ($do_funky eq "2") {
+ } else {
# cygwin utilities version (http://www.cygwin.com)
$directory_name =~ s/^(.):[\\\/](.*)$/\/cygdrive\/\1\/\2/;
}
# these are endings that we consider unimportant. where a caret is used
# at the front, we will match only the whole string. double slashes are
# used before periods to ensure we match a real period character.
-
-# "AssemblyInfo.c.*",
-#need to regenerate these automatically.
-
local(@junk_files) = ("~", "^\\.#.*", "^\\._.*", "\\.aps", "\\.bak",
- "^binaries",
- "\\.clw", "^cpdiff_tmp\\.txt", "^Debug", "^\\.ds_store", "^diffs\\.txt",
+ "^binaries",
+ "\\.clw", "^cpdiff_tmp\\.txt", "^\\.ds_store", "^diffs\\.txt",
"^diff_tmp\\.txt", "\\.dsp", "\\.dsw", "\\.gid", "gmon\\.out", "\\.isr",
"^isconfig\\.ini", "\\.log", "^manifest.txt", "^obj",
"\\.obj", "\\.output", "\\.plg", "^RCa.*", "^Release", "\\.res",
"\\.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");
-#this whacks too much. what was it for?
-#"^generated_.*",
foreach $temp (@junk_files) {
$temp = $temp . '$';
# 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) {