| package Archive::Zip::MockFileHandle; |
| # Output file handle that calls a custom write routine |
| # This is provided to help with writing zip files |
| # when you have to process them a chunk at a time. |
| $VERSION = eval $VERSION; |
| my $class = shift || __PACKAGE__; |
| $class = ref($class) || $class; |
| return $self->{'position'} >= $self->{'size'}; |
| # Copy given buffer to me |
| my $bytes = join( '', @_ ); |
| my $bytesWritten = $self->writeHook($bytes); |
| if ( $self->{'position'} + $bytesWritten > $self->{'size'} ) { |
| $self->{'size'} = $self->{'position'} + $bytesWritten; |
| $self->{'position'} += $bytesWritten; |
| # Override in subclasses. |
| # Return number of bytes written (0 on error). |
| sub tell { return shift->{'position'} } |