Strip drive and dir root from listing
authorShabe Razvi <shaber@symbian.org>
Thu, 30 Apr 2009 16:09:08 +0100
changeset 78 52cc4f7310db
parent 77 89903a4399c7
child 79 d9875e573161
Strip drive and dir root from listing
common/tools/listdir.pl
--- a/common/tools/listdir.pl	Thu Apr 30 10:00:16 2009 +0100
+++ b/common/tools/listdir.pl	Thu Apr 30 16:09:08 2009 +0100
@@ -3,12 +3,15 @@
 
 my $dir      = shift or die "Usage: $0 <dir> \n";   #  provided dir to traverse
 my $filelist = [];
+my $init = $dir = lc($dir);
+$init =~ s{\\}{\\\\};
 
 # fwd declaration to prevent warning
 sub recursedir($$);
 
 # run recurse and print
 recursedir ($dir, $filelist);
+
 print $_, "\n" for(@$filelist);
 
 sub recursedir($$) {
@@ -19,15 +22,14 @@
   if(opendir(DIR, "$dir")) {
     #  list dir
     for my $file(grep { !/^\./ } readdir DIR) {
-      if(-d "$dir\\$file") {
+      if(-d "$dir/$file") {
         #  traverse subdirs
-        recursedir("$dir\\$file", $list);
+        recursedir("$dir/$file", $list);
       }
-      elsif(-f "$dir\\$file") {
-        #  if file then swap (any present) fwd to bkslash and add to list        
-        $dir   =~s/\//\\/;
-        $file  =~s/\//\\/;
-        push @$list, "$dir\\$file";
+      elsif(-f "$dir/$file") {
+        my $formatted = lc($dir)."/".lc($file);
+        $formatted =~ s!$init/!!;
+        push @$list, $formatted;
       }
     }
     closedir DIR;