1 package Archive
::Zip
::MockFileHandle
;
3 # Output file handle that calls a custom write routine
5 # This is provided to help with writing zip files
6 # when you have to process them a chunk at a time.
10 use vars
qw{$VERSION};
14 $VERSION = eval $VERSION;
18 my $class = shift || __PACKAGE__
;
19 $class = ref($class) || $class;
32 return $self->{'position'} >= $self->{'size'};
35 # Copy given buffer to me
38 my $bytes = join( '', @_ );
39 my $bytesWritten = $self->writeHook($bytes);
40 if ( $self->{'position'} + $bytesWritten > $self->{'size'} ) {
41 $self->{'size'} = $self->{'position'} + $bytesWritten;
43 $self->{'position'} += $bytesWritten;
47 # Called on each write.
48 # Override in subclasses.
49 # Return number of bytes written (0 on error).
53 return length($bytes);
65 sub tell { return shift->{'position'} }