8 use IO::Uncompress::RawInflate qw(:all);
11 die "Usage: zipcat file\n"
16 my $fh = new IO::File "<$file"
17 or die "Cannot open '$file': $!\n";
21 my $FIXED_HEADER_LENGTH = 30 ;
26 ($x = $fh->read($buffer, $FIXED_HEADER_LENGTH)) == $FIXED_HEADER_LENGTH
27 or die "Truncated file top: $x $!\n";
29 my $signature = unpack ("V", substr($buffer, 0, 4));
31 last unless $signature == 0x04034b50;
33 my $compressedMethod = unpack ("v", substr($buffer, 8, 2));
34 my $compressedLength = unpack ("V", substr($buffer, 18, 4));
35 #my $uncompressedLength = unpack ("V", substr($buffer, 22, 4));
36 my $filename_length = unpack ("v", substr($buffer, 26, 2));
37 my $extra_length = unpack ("v", substr($buffer, 28, 2));
39 warn "Compressed Length $compressedLength\n";
41 $fh->read($filename, $filename_length) == $filename_length
42 or die "Truncated file\n";
44 $fh->read($buffer, $extra_length) == $extra_length
45 or die "Truncated file\n";
47 if ($compressedMethod != 8 && $compressedMethod != 0)
49 warn "Skipping file '$filename' - not deflated $compressedMethod\n";
50 $fh->read($buffer, $compressedLength) == $compressedLength
51 or die "Truncated file\n";
55 next if $compressedLength == 0;
57 warn "Writing file '$filename' $compressedMethod\n";
59 #mkpath dirname $filename;
61 #rawinflate $fh => $filename,
62 rawinflate $fh => '-',
64 InputLength => $compressedLength
65 or die "Error uncompressing $file [$filename]: $RawInflateError\n" ;
68 sub decodeLocalFileHeader