@ISA = qw(Exporter IO::File);
-$VERSION = '2.008';
+$VERSION = '2.009';
use constant G_EOF => 0 ;
use constant G_ERR => -1 ;
-use IO::Compress::Base::Common 2.008 ;
+use IO::Compress::Base::Common 2.009 ;
#use Parse::Parameters ;
use IO::File ;
#Exporter::export_ok_tags('all') ;
+
sub smartRead
{
my $self = $_[0];
my $get_size = $size - $offset ;
- #if ( defined *$self->{InputLength} ) {
- # $get_size = min($get_size, *$self->{InputLengthRemaining});
- #}
-
- if (defined *$self->{FH})
- { *$self->{FH}->read($$out, $get_size, $offset) }
+ if (defined *$self->{FH}) {
+ if ($offset) {
+ # Not using this
+ #
+ # *$self->{FH}->read($$out, $get_size, $offset);
+ #
+ # because the filehandle may not support the offset parameter
+ # An example is Net::FTP
+ my $tmp = '';
+ *$self->{FH}->read($tmp, $get_size) > 0 &&
+ (substr($$out, $offset) = $tmp);
+ }
+ else
+ { *$self->{FH}->read($$out, $get_size) }
+ }
elsif (defined *$self->{InputEvent}) {
my $got = 1 ;
while (length $$out < $size) {
return 0 if length *$self->{Prime} || *$self->{PushMode};
if (defined *$self->{FH})
- { *$self->{FH}->eof() }
+ {
+ # Could use
+ #
+ # *$self->{FH}->eof()
+ #
+ # here, but this can cause trouble if
+ # the filehandle is itself a tied handle, but it uses sysread.
+ # Then we get into mixing buffered & non-buffered IO, which will cause trouble
+
+ my $info = $self->getErrInfo();
+
+ my $buffer = '';
+ my $status = $self->smartRead(\$buffer, 1);
+ $self->pushBack($buffer) if length $buffer;
+ $self->setErrInfo($info);
+
+ return $status == 0 ;
+ }
elsif (defined *$self->{InputEvent})
{ *$self->{EventEof} }
else
${ *$self->{Error} } = '' ;
}
+sub getErrInfo
+{
+ my $self = shift ;
+
+ return [ *$self->{ErrorNo}, ${ *$self->{Error} } ] ;
+}
+
+sub setErrInfo
+{
+ my $self = shift ;
+ my $ref = shift;
+
+ *$self->{ErrorNo} = $ref->[0] ;
+ ${ *$self->{Error} } = $ref->[1] ;
+}
+
sub saveStatus
{
my $self = shift ;
my $magic = $self->ckMagic();
#*$self->{EndStream} = 0 ;
- if ( ! $magic) {
+ if ( ! defined $magic) {
if (! *$self->{Transparent} )
{
*$self->{EndStream} = 1 ;
=head1 NAME
-
IO::Uncompress::Base - Base Class for IO::Uncompress modules
-
=head1 SYNOPSIS
use IO::Uncompress::Base ;
=head1 DESCRIPTION
-
This module is not intended for direct use in application code. Its sole
purpose if to to be sub-classed by IO::Unompress modules.
-
-
-
=head1 SEE ALSO
L<Compress::Zlib>, L<IO::Compress::Gzip>, L<IO::Uncompress::Gunzip>, L<IO::Compress::Deflate>, L<IO::Uncompress::Inflate>, L<IO::Compress::RawDeflate>, L<IO::Uncompress::RawInflate>, L<IO::Compress::Bzip2>, L<IO::Uncompress::Bunzip2>, L<IO::Compress::Lzop>, L<IO::Uncompress::UnLzop>, L<IO::Compress::Lzf>, L<IO::Uncompress::UnLzf>, L<IO::Uncompress::AnyInflate>, L<IO::Uncompress::AnyUncompress>
L<Archive::Tar|Archive::Tar>,
L<IO::Zlib|IO::Zlib>
-
-
-
-
=head1 AUTHOR
This module was written by Paul Marquess, F<pmqs@cpan.org>.
-
-
=head1 MODIFICATION HISTORY
See the Changes file.
=head1 COPYRIGHT AND LICENSE
-Copyright (c) 2005-2007 Paul Marquess. All rights reserved.
+Copyright (c) 2005-2008 Paul Marquess. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
-