develooper Front page | perl.perl5.porters | Postings from April 2006

FileHandle isa IO::Seekable?

Thread Next
From:
Adam Kennedy
Date:
April 29, 2006 21:12
Subject:
FileHandle isa IO::Seekable?
Message ID:
20060430041241.28059.qmail@lists.develooper.com
Having just taken over a co-maint on Archive::Zip to do some Win32 
stuff, I've encountered a problem in that Archive::Zip needs seekable 
file handles.

So as such, is has an _isSeekable function in which it splits out the 
cases it knows it can handle from those it knows it can't.

Thinking that it was being a bit dumb in not working with IO::Seekable, 
I added

if ( UNIVERSAL::isa($fh, 'IO::Seekable') ) {
	return 1;
}

(lets ignore the fact I'm not using isa as a method for now, since it's 
also done a hundred other places in this code, and I'll deal with that 
problem a bit later)

The problem is that one of the tests includes a FileHandle object which 
opens a pipe.

Now, it appears that for a while, FileHandle has been made @ISA = qw{ 
IO::File } and of course IO::File @ISA = qw{ IO::Handle IO::Seekable };

But of course, pipes may be able to ->tell, but they certainly aren't 
seekable. So is it really correct for FileHandle to be an IO::File 
subclass, of not everything a FileHandle opens isa file?

That question aside, is there some way to tell whether something is 
ACTUALLY seekable, rather than it just having a ->seek method?

Adam K

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About