Subject: | tied seek/tell error return |
Date: | Sun, 25 Nov 2012 07:39:12 +1100 |
To: | bug-IO-Zlib [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
With recent debian i386 perl 5.14.2 and its included IO::Zlib 1.10, running
system "echo hi >/tmp/foo.txt";
system "gzip /tmp/foo.txt";
use IO::Zlib;
tie *FH, 'IO::Zlib', "/tmp/foo.txt.gz", "rb";
seek FH, 0,0;
dies with
Not a GLOB reference at /usr/share/perl/5.14/IO/Zlib.pm line 559.
where I hoped that seek() would return false with $!, as for other file
handles.
Perhaps the couple of lines below, pending possible future
gzseek/gztell.
# No seek() yet.
#
# With Compress::Zlib could gzseek() to support forward seeks and
# gztell() for current position.
#
# With external gunzip could read and discard to seek forward. Might
# have to remember the file position explicitly to support TELL.
#
# POSIX.1 specifies ESPIPE for attempting to seek a pipe. Maybe could
# return that if available, instead of EINVAL.
#
sub SEEK {
require POSIX;
$! = POSIX::EINVAL();
return 0;
}
sub TELL {
require POSIX;
$! = POSIX::EINVAL();
return -1;
}