B
bmowder
All-
I'm using ActivePerl v5.8.7 built for MSWin32-x86-multi-thread,
Binary build 813 on a windows XP Professional SP2 machine The modules
in use are Archive::Tar V 1.23 and
Compress::Zlib v1.34.
I have been trying to uncompress a tar.Z file so I could open it with
Archive::Tar and extract the contents, but have had no success
whatsoever. I tried Archive::Zip, but it maintains that the files are
NOT .zip files.
I have tried:
for $compressed ( <*.tar.Z> ) {
($outname = $compressed) =~ s/[.]Z$//;
$input="";
$output="";
$istat="";
$ostat="";
$tar= Archive::Tar->new($compressed, 1) or die "Couldn't read file
$compressed\n";
exit(0);
}
Which fails with the message "Can not read compressed format in
tar-mode"
I have tried:
for $compressed ( <*.tar.Z> ) {
($outname = $compressed) =~ s/[.]Z$//;
$input="";
$output="";
$i="";
$istat="";
$ostat="";
($i,$istat)=inflateInit(WindowBits => -Compress::Zlib::MAX_WBITS())
or die "Cannot create a inflation stream\n" ;;
open INFILE, "<$compressed" or die "Couldn't open $compressed to read
$!\n";
open OUTFILE, ">$outname" or die "Couldn't open $outname to write
$!\n";
binmode INFILE;
binmode OUTFILE;
while ( read(INFILE, $inline, 4096) > 0 ) {
$input .= $inline;
}
$input .= " "; #add trailing byte
per Doc.
($output, $status) = $i->inflate(\$input) ;
print OUTFILE $output if $status == Z_OK or $status == Z_STREAM_END ;
close(INFILE);
close(OUTFILE);
die "inflation failed $status\n" unless $status == Z_STREAM_END ;
exit(0);
}
Which fails with the message "inflation failed -3" (-3 translates as
Z_DATA_ERROR)
I have tried:
for $compressed ( <*.tar.Z> ) {
($outname = $compressed) =~ s/[.]Z$//;
$input="";
$output="";
$istat="";
$ostat="";
open INFILE, "<$compressed" or die "Couldn't open $compressed to read
$!\n";
open OUTFILE, ">$outname" or die "Couldn't open $outname to write
$!\n";
binmode INFILE;
binmode OUTFILE;
while ( (read(INFILE, $inline, 4096)) > 0 ) {
$input .= $inline;
}
close(INFILE);
if ( ($output=uncompress($input)) eq undef ) {
die "uncompress failed for $compressed\n";
} else {
print OUTFILE $output;
}
close(OUTFILE);
exit(0);
}
Which fails with the message "uncompress failed for
AT1355_20050930191102.tar.Z"
And a whole lot of other things too tedious to mention, all of which
leaves me wondering,
Has anyone ever succeeded in uncompressing a tar.Z file so that the
..tar file could be accessed in perl, using Compress::Zlib and/or
Archive::Tar on a WIn32 OS?
If anyone has succeeded in doing this, PLEASE tell me how (what
modules, what methods)? Sample code would be most appreciated.
Barney.
I'm using ActivePerl v5.8.7 built for MSWin32-x86-multi-thread,
Binary build 813 on a windows XP Professional SP2 machine The modules
in use are Archive::Tar V 1.23 and
Compress::Zlib v1.34.
I have been trying to uncompress a tar.Z file so I could open it with
Archive::Tar and extract the contents, but have had no success
whatsoever. I tried Archive::Zip, but it maintains that the files are
NOT .zip files.
I have tried:
for $compressed ( <*.tar.Z> ) {
($outname = $compressed) =~ s/[.]Z$//;
$input="";
$output="";
$istat="";
$ostat="";
$tar= Archive::Tar->new($compressed, 1) or die "Couldn't read file
$compressed\n";
exit(0);
}
Which fails with the message "Can not read compressed format in
tar-mode"
I have tried:
for $compressed ( <*.tar.Z> ) {
($outname = $compressed) =~ s/[.]Z$//;
$input="";
$output="";
$i="";
$istat="";
$ostat="";
($i,$istat)=inflateInit(WindowBits => -Compress::Zlib::MAX_WBITS())
or die "Cannot create a inflation stream\n" ;;
open INFILE, "<$compressed" or die "Couldn't open $compressed to read
$!\n";
open OUTFILE, ">$outname" or die "Couldn't open $outname to write
$!\n";
binmode INFILE;
binmode OUTFILE;
while ( read(INFILE, $inline, 4096) > 0 ) {
$input .= $inline;
}
$input .= " "; #add trailing byte
per Doc.
($output, $status) = $i->inflate(\$input) ;
print OUTFILE $output if $status == Z_OK or $status == Z_STREAM_END ;
close(INFILE);
close(OUTFILE);
die "inflation failed $status\n" unless $status == Z_STREAM_END ;
exit(0);
}
Which fails with the message "inflation failed -3" (-3 translates as
Z_DATA_ERROR)
I have tried:
for $compressed ( <*.tar.Z> ) {
($outname = $compressed) =~ s/[.]Z$//;
$input="";
$output="";
$istat="";
$ostat="";
open INFILE, "<$compressed" or die "Couldn't open $compressed to read
$!\n";
open OUTFILE, ">$outname" or die "Couldn't open $outname to write
$!\n";
binmode INFILE;
binmode OUTFILE;
while ( (read(INFILE, $inline, 4096)) > 0 ) {
$input .= $inline;
}
close(INFILE);
if ( ($output=uncompress($input)) eq undef ) {
die "uncompress failed for $compressed\n";
} else {
print OUTFILE $output;
}
close(OUTFILE);
exit(0);
}
Which fails with the message "uncompress failed for
AT1355_20050930191102.tar.Z"
And a whole lot of other things too tedious to mention, all of which
leaves me wondering,
Has anyone ever succeeded in uncompressing a tar.Z file so that the
..tar file could be accessed in perl, using Compress::Zlib and/or
Archive::Tar on a WIn32 OS?
If anyone has succeeded in doing this, PLEASE tell me how (what
modules, what methods)? Sample code would be most appreciated.
Barney.