Subject: | readScalar.pl is failing |
Using the Archive::Zip 1.13 the readScalar.pl script fails like so:
[andy@andy-p4-linux tmp]$ ./readScalar.pl
Read 20000 bytes
error: file not seekable
Archive::Zip::Archive::readFromFileHandle('Archive::Zip::Archive=HASH(0x839e548)','IO::Scalar=GLOB(0x839e554)') called at ./readScalar.pl line 20
The exact code used is below (identical to examples/readScalar.pl from the Archive::Zip package, with a changed filename):
#!/usr/bin/perl -w
# Demonstrates reading a zip from an IO::Scalar
# $Revision: 1.4 $
use strict;
use Archive::Zip qw(:CONSTANTS :ERROR_CODES);
use IO::Scalar;
use IO::File;
# test reading from a scalar
my $file = IO::File->new('maze-logos.zip', 'r');
my $zipContents;
binmode($file);
$file->read($zipContents, 20000);
$file->close();
printf "Read %d bytes\n", length($zipContents);
my $SH = IO::Scalar->new(\$zipContents);
my $zip = Archive::Zip->new();
$zip->readFromFileHandle( $SH );
my $member = $zip->addString('c' x 300, 'bunchOfCs.txt');
$member->desiredCompressionMethod(COMPRESSION_DEFLATED);
$member = $zip->addString('d' x 300, 'bunchOfDs.txt');
$member->desiredCompressionMethod(COMPRESSION_DEFLATED);
$zip->writeToFileNamed('maze-logos2.zip');
------------------------
The above script fails with all available versions of Archive::Zip, but for version 1.10 and below it has a different error message, and my own script (XMLTV's tv_grab_uk_bleb:
http://cvs.sourceforge.net/viewcvs.py/xmltv/xmltv/grab/uk_bleb/tv_grab_uk_bleb.in?rev=1.5&view=markup
works fine with version 1.10 and below.)
The error message given with version 1.10 and below from readScalar.pl is as follows:
[andy@andy-p4-linux tmp]$ ./readScalar.pl
Read 20000 bytes
format error: can't find EOCD signature
Archive::Zip::Archive::_findEndOfCentralDirectory('Archive::Zip::Archive=HASH(0x80cf6f4)','IO::Scalar=GLOB(0x80cf700)') called at /usr/lib/perl5/site_perl/5.8.0/Archive/Zip.pm line 945
Archive::Zip::Archive::readFromFileHandle('Archive::Zip::Archive=HASH(0x80cf6f4)','IO::Scalar=GLOB(0x80cf700)') called at ./readScalar.pl line 20
which looks like a different issue.
----------
Looking at line 49 of Zip.pm;
# TODO: how to support non-seekable zips?
return _error('file not seekable')
unless _isSeekable($fh);
this looks like a known issue.
---------------
I'd like to do anything I can to help resolve this as this functionality is very useful to me.
--------------
System:
RedHat 9:
[andy@andy-p4-linux andy]$ uname -a
Linux andy-p4-linux 2.4.20-20.9 #1 Mon Aug 18 11:45:58 EDT 2003 i686 i686 i386 GNU/Linux
[andy@andy-p4-linux andy]$ perl -v
This is perl, v5.8.0 built for i386-linux-thread-multi
(with 1 registered patch, see perl -V for more detail)