Add code to automatically uncompress .gz and .bz2 files that are given as arguments.

git-svn-id: svn://10.0.0.236/trunk@228405 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dbaron%dbaron.org 2007-06-20 21:59:33 +00:00
parent 7b75c6c09f
commit 23c2d9146e

View File

@ -127,7 +127,15 @@ sub add_file($$) {
my ($infile, $factor) = @_;
open (INFILE, "<$infile") || die "Can't open input \"$infile\"";
if ($infile =~ /\.bz2$/) {
# XXX This doesn't propagate errors from bzip2.
open (INFILE, "bzip2 -cd '$infile' |") || die "Can't open input \"$infile\"";
} elsif ($infile =~ /\.gz$/) {
# XXX This doesn't propagate errors from gzip.
open (INFILE, "gzip -cd '$infile' |") || die "Can't open input \"$infile\"";
} else {
open (INFILE, "<$infile") || die "Can't open input \"$infile\"";
}
while ( ! eof(INFILE) ) {
# read the type and address
my $line = <INFILE>;