Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Archive-Zip CPAN distribution.

Report information
The Basics
Id:
7633
Status:
open
Priority:
Low/Low
Queue:

People
Owner:
nedkonz [...] cpan.org (email delivery suspended)
Requestors:
andybalaam [...] artificialworlds.net
Cc:
AdminCc:

BugTracker
Severity:
(no value)
Broken in:
1.13
Fixed in:
(no value)



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)
Well, since IO::Scalar and IO::String have apparently been seekable since Perl 5.6 (I don't use Perl any more), why not try just changing _isSeekable to have something like: sub _isSeekable # Archive::Zip { my $fh = shift; if ( UNIVERSAL::isa( $fh, 'IO::Scalar' ) ) { return $] >= 5.006; } elsif ( UNIVERSAL::isa( $fh, 'IO::String' ) ) { return $] >= 5.006; } elsif ( UNIVERSAL::can( $fh, 'stat' ) ) { return -f $fh; } return UNIVERSAL::can( $fh, 'seek' ); } I haven't tried this, but you might do so. And of course you can also pass a reference to a string to open() in Perl 5.8; have you tried file handles opened that way?
From: Andy Balaam
The attached patch does as you suggested, and fixes my problem. Thanks very much. Will you commit the change, or should I do something to make it happen? Thanks, Andy
diff -r -uBb Archive-Zip-1.13/lib/Archive/Zip.pm Archive-Zip-1.13-modified/lib/Archive/Zip.pm --- Archive-Zip-1.13/lib/Archive/Zip.pm 2004-08-23 14:27:39.000000000 +0100 +++ Archive-Zip-1.13-modified/lib/Archive/Zip.pm 2004-09-14 09:59:34.000000000 +0100 @@ -313,11 +313,11 @@ if ( UNIVERSAL::isa( $fh, 'IO::Scalar' ) ) { - return 0; + return $] >= 5.006; } elsif ( UNIVERSAL::isa( $fh, 'IO::String' ) ) { - return 1; + return $] >= 5.006; } elsif ( UNIVERSAL::can( $fh, 'stat' ) ) {
[NEDKONZ - Mon Sep 13 19:12:36 2004]:
Show quoted text
> Well, since IO::Scalar and IO::String have apparently been seekable > since Perl 5.6 (I don't use Perl any more), why not try just changing > _isSeekable to have something like: > > sub _isSeekable # Archive::Zip > { > my $fh = shift; > > if ( UNIVERSAL::isa( $fh, 'IO::Scalar' ) ) > { > return $] >= 5.006; > } > elsif ( UNIVERSAL::isa( $fh, 'IO::String' ) ) > { > return $] >= 5.006; > } > elsif ( UNIVERSAL::can( $fh, 'stat' ) ) > { > return -f $fh; > } > return UNIVERSAL::can( $fh, 'seek' ); > } > > I haven't tried this, but you might do so. > > And of course you can also pass a reference to a string to open() in > Perl 5.8; have you tried file handles opened that way?
I'm, unfortunately, getting the "format error: can't find EOCD signature" error with this patch. I'll back up a few versions to see if this goes away. If it does, I should be able to narrow down the cause very quickly. This should be resolved for the next release.
From: Andy Balaam
[SMPETERS - Fri Mar 11 09:34:47 2005]:
Show quoted text
> I'm, unfortunately, getting the "format error: can't find EOCD > signature" error with this patch. I'll back up a few versions to see if > this goes away. If it does, I should be able to narrow down the cause > very quickly. This should be resolved for the next release.
Have you made any progress on this?
Trying to clean up some RT tickets here. Is this still an issue? Does the latest revision fix the problem?
CC: SMPETERS@cpan.org
Subject: Re: [rt.cpan.org #7633] readScalar.pl is failing
Date: Thu, 19 Apr 2012 19:50:35 +0100
To: bug-Archive-Zip@rt.cpan.org
From: Andy Balaam <andybalaam@artificialworlds.net>
I still get the same error when running the same script, with perl v5.12.4 and Archive::Zip 1.30. (on Ubuntu 12.04) I also still get the same error when running examples/readScalar.pl


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.