From b3d8a97447bdaf8040d095777badce1d1bbc5d7b Mon Sep 17 00:00:00 2001 From: "seawood%netscape.com" Date: Sat, 29 Sep 2001 07:09:33 +0000 Subject: [PATCH] Recurse all directories regardless of whether .headerlist exists but only remove files from dirs with .headerlist. r=jag --- config/purge-old-headers.pl | 51 ++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/config/purge-old-headers.pl b/config/purge-old-headers.pl index e49dc1d66c9..bab27c6194d 100644 --- a/config/purge-old-headers.pl +++ b/config/purge-old-headers.pl @@ -49,13 +49,14 @@ sub purge($) { my ($dirname) = @_; my ($file, $dir, $tmp, $listfile); my (@dirlist, @filelist, @masterlist, @removelist); - - #print "Inside purge: $dirname, $listfile\n"; + my $ignoredir = 0; $listfile = "$dirname/.headerlist"; - # Return if master listfile does not exist - return if (! -e "$listfile" ); + #print "Inside purge: $dirname, $listfile\n"; + + # Ignore files and just process subdirs if there's no master filelist + $ignoredir = 1 if (! -e "$listfile" ); # Create lists of current files and subdirectories my $SDIR = new IO::Handle; @@ -65,25 +66,27 @@ sub purge($) { if ( -d "$dirname/$file" ) { push @dirlist, "$file"; } else { - push @filelist, "$file"; + push @filelist, "$file" if (!$ignoredir); } } closedir($SDIR); - # Read in "master" file list - undef @masterlist; - my $MLIST = new IO::Handle; - open($MLIST, "$listfile") || die "$listfile: $!\n"; - while ($tmp = <$MLIST>) { - chomp($tmp); - push @masterlist, "$tmp"; - } - close($MLIST); + if (!$ignoredir) { + # Read in "master" file list + undef @masterlist; + my $MLIST = new IO::Handle; + open($MLIST, "$listfile") || die "$listfile: $!\n"; + while ($tmp = <$MLIST>) { + chomp($tmp); + push @masterlist, "$tmp"; + } + close($MLIST); - # compare master list with read list - undef @removelist; - foreach $file (@filelist) { - push @removelist, $file if (!grep(/$file/, @masterlist)); + # compare master list with read list + undef @removelist; + foreach $file (@filelist) { + push @removelist, $file if (!grep(/$file/, @masterlist)); + } } # Call purge recursively @@ -92,14 +95,16 @@ sub purge($) { purge("$dirname/$dir"); } - # Remove files - foreach $file (@removelist) { - print "purge old header: $dirname/$file\n"; - unlink("$dirname/$file"); + if (!$ignoredir) { + # Remove files + foreach $file (@removelist) { + print "purge old header: $dirname/$file\n"; + unlink("$dirname/$file"); + } } #Unlink listfile now that we're done processing this dir - unlink("$listfile"); + unlink("$listfile") if (!$ignoredir); }