Skip to content

Instantly share code, notes, and snippets.

@kshoji
Created October 30, 2013 08:30
Show Gist options
  • Save kshoji/7228989 to your computer and use it in GitHub Desktop.
Save kshoji/7228989 to your computer and use it in GitHub Desktop.
Bug fix for the CPAN module Archive::Zip. The error `IO error: seeking to rewrite local header : Illegal seek` happened when write to the STDOUT.
# patch for Archive/Zip/Member.pm
# search the 'bitFlag' subroutine and replace it.
sub bitFlag {
my $self = shift;
# Set General Purpose Bit Flags according to the desiredCompressionLevel setting
my $hasDataDescriptor = $self->hasDataDescriptor();
if ( $self->desiredCompressionLevel == 1 || $self->desiredCompressionLevel == 2 ) {
$self->{'bitFlag'} = DEFLATING_COMPRESSION_FAST | $hasDataDescriptor;
} elsif ( $self->desiredCompressionLevel == 3 || $self->desiredCompressionLevel == 4
|| $self->desiredCompressionLevel == 5 || $self->desiredCompressionLevel == 6
|| $self->desiredCompressionLevel == 7 ) {
$self->{'bitFlag'} = DEFLATING_COMPRESSION_NORMAL | $hasDataDescriptor;
} elsif ( $self->desiredCompressionLevel == 8 || $self->desiredCompressionLevel == 9 ) {
$self->{'bitFlag'} = DEFLATING_COMPRESSION_MAXIMUM | $hasDataDescriptor;
}
$self->{'bitFlag'};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment