File:  [mozdev] / abacus / removeNewLines.pl
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Thu Sep 9 06:43:31 2004 UTC (13 years, 1 month ago) by ajvincent
Branches: MAIN
CVS tags: HEAD
*** empty log message ***

use strict;
use File::Spec;
my @dir_list;
$dir_list[0] = "./";
my @file_list;
my $dir_count = 1;
my $current_dir = 0;
my $file_count = 0;
for $current_dir (@dir_list) {
  opendir(DIR, $current_dir);
  my @subdirs = File::Spec->no_upwards(readdir(DIR));
  for my $subdir (@subdirs) {
    my $fileName = $current_dir.$subdir;
    if (-d $fileName) {
      $dir_list[$dir_count] = $fileName."/";
      mkdir("../abacusNew/$fileName/");
      $dir_count++;
    } else {
      if ($fileName =~ m/$\.(css|dtd|js|pl|properties|rdf|txt|xul|xml|html|xsl)/ ) {
        $file_list[$file_count] = $fileName;
        $file_count++;
      }
    }
  }
  $current_dir++;
  closedir(DIR);
}

my $log = "";
for my $fileName (@file_list) {
  open (ABACUS, "< $fileName");
  my $fileText = "";
  while (my $line = <ABACUS>) {
    $fileText .= $line;
  }
  close(ABACUS);
  $fileText =~ s/\r\n/\n/g;
  if ($fileText =~ m/\r\n/) {
    die($fileName . " did not lose all newlines!");
  } else {
    open (ABACUS_OUT, "> $fileName");
    print ABACUS_OUT $fileText or die("Couldn't write file $fileName!\n");
    close(ABACUS_OUT);
    $log .= "$fileName\n";
  }
}

open (LOG, ">> newLinesLog.txt");
my $time = localtime();
print LOG "*** START OF LOG at $time.\nFiles successfully cleared of \\r\\n:\n";
print LOG $log;
print LOG "*** END OF LOG at $time.\n\n";
close (LOG);

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>