Fix handling of directories of builds
authorWilliam Roberts <williamr@symbian.org>
Fri, 27 Aug 2010 15:38:43 +0100
changeset 309 a265a2da5fcb
parent 308 c62bd4f9dbce
child 310 46889a3f0a06
Fix handling of directories of builds
williamr/delete_builds.pl
--- a/williamr/delete_builds.pl	Fri Aug 27 15:27:06 2010 +0100
+++ b/williamr/delete_builds.pl	Fri Aug 27 15:38:43 2010 +0100
@@ -53,10 +53,29 @@
     }
   if (!-d "$dir/output")
     {
-    print "Ignoring $dir - not a build\n";
-    next;
+    # not a build - perhaps a directory of builds?
+    opendir DIR, $dir;
+    my @files = grep !/^\.\.?$/, readdir DIR;
+    closedir DIR;
+    
+    my @subbuilds = ();
+    foreach my $file (@files)
+      {
+      next if (!-d "$dir/$file");
+      next if (!-d "$dir/$file/output");
+      push @subbuilds, "$dir/$file";
+      }
+    if (scalar @subbuilds == 0)
+      {
+      print "Ignoring $dir - not a build and contains no builds\n";
+      next;
+      }
+    push @builds, @subbuilds;
     }
-  push @builds, $dir;
+  else
+    {
+    push @builds, $dir;
+    }
   }
 
 foreach my $subdir (@rich_pickings)
@@ -74,6 +93,6 @@
 foreach my $build (@builds)
   {
   $build =~ s/\//\\/g;
-  print "* rmdir /s/q $build";
+  print "* rmdir /s/q $build\n";
   system("rmdir","/s/q",$build);   
   }