| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Archive::Zip::StreamedUnzip; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | require 5.006; | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 1 |  |  | 1 |  | 729 | use strict ; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 24 |  | 
| 6 | 1 |  |  | 1 |  | 4 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 19 |  | 
| 7 | 1 |  |  | 1 |  | 3 | use bytes; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 3 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 1 |  |  | 1 |  | 16 | use IO::File; | 
|  | 1 |  |  |  |  | 14 |  | 
|  | 1 |  |  |  |  | 138 |  | 
| 10 | 1 |  |  | 1 |  | 8 | use Carp; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 79 |  | 
| 11 | 1 |  |  | 1 |  | 6 | use Scalar::Util (); | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 35 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 | 1 |  |  | 1 |  | 5 | use IO::Compress::Base::Common  2.201 qw(:Status); | 
|  | 1 |  |  |  |  | 14 |  | 
|  | 1 |  |  |  |  | 91 |  | 
| 14 | 1 |  |  | 1 |  | 6 | use IO::Compress::Zip::Constants 2.201 ; | 
|  | 1 |  |  |  |  | 13 |  | 
|  | 1 |  |  |  |  | 160 |  | 
| 15 | 1 |  |  | 1 |  | 6 | use IO::Uncompress::Unzip 2.201 ; | 
|  | 1 |  |  |  |  | 12 |  | 
|  | 1 |  |  |  |  | 203 |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | require Exporter ; | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $StreamedUnzipError); | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | $VERSION = '1.000'; | 
| 23 |  |  |  |  |  |  | $StreamedUnzipError = ''; | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | @ISA    = qw(IO::Uncompress::Unzip Exporter); | 
| 26 |  |  |  |  |  |  | @EXPORT_OK = qw( $StreamedUnzipError unzip ); | 
| 27 |  |  |  |  |  |  | %EXPORT_TAGS = %IO::Uncompress::RawInflate::EXPORT_TAGS ; | 
| 28 |  |  |  |  |  |  | push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ; | 
| 29 |  |  |  |  |  |  | Exporter::export_ok_tags('all'); | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | sub _setError | 
| 33 |  |  |  |  |  |  | { | 
| 34 | 4 |  |  | 4 |  | 93 | $StreamedUnzipError = $_[2] ; | 
| 35 | 4 | 50 |  |  |  | 7 | $_[0]->{Error} = $_[2] | 
| 36 |  |  |  |  |  |  | if defined  $_[0] ; | 
| 37 |  |  |  |  |  |  |  | 
| 38 | 4 |  |  |  |  | 11 | return $_[1]; | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | sub _illegalFilename | 
| 42 |  |  |  |  |  |  | { | 
| 43 | 2 |  |  | 2 |  | 4 | return _setError(undef, undef, "Illegal Filename") ; | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | sub is64BitPerl | 
| 47 |  |  |  |  |  |  | { | 
| 48 | 1 |  |  | 1 |  | 5 | use Config; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 1403 |  | 
| 49 |  |  |  |  |  |  | # possibly use presence of pack/unpack "Q" for int size test? | 
| 50 | 0 | 0 |  | 0 | 0 | 0 | $Config{lseeksize} >= 8 and $Config{uvsize} >= 8; | 
| 51 |  |  |  |  |  |  | } | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | sub new | 
| 54 |  |  |  |  |  |  | { | 
| 55 | 88 |  |  | 88 | 1 | 4099 | my $class = shift ; | 
| 56 |  |  |  |  |  |  |  | 
| 57 | 88 | 100 |  |  |  | 236 | return _setError(undef, undef, "Missing Filename") | 
| 58 |  |  |  |  |  |  | unless @_ ; | 
| 59 |  |  |  |  |  |  |  | 
| 60 | 87 |  |  |  |  | 134 | my $inValue = shift ; | 
| 61 | 87 |  |  |  |  | 114 | my $fh; | 
| 62 |  |  |  |  |  |  |  | 
| 63 | 87 | 100 |  |  |  | 160 | if (!defined $inValue) | 
| 64 |  |  |  |  |  |  | { | 
| 65 | 1 |  |  |  |  | 3 | return _illegalFilename | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  |  | 
| 68 | 86 |  |  |  |  | 191 | my $isSTDOUT = ($inValue eq '-') ; | 
| 69 | 86 |  |  |  |  | 209 | my $inType = IO::Compress::Base::Common::whatIsOutput($inValue); | 
| 70 |  |  |  |  |  |  |  | 
| 71 | 86 | 100 | 33 |  |  | 2254 | if ($inType eq 'filename') | 
|  |  | 50 |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | { | 
| 73 | 58 | 100 | 66 |  |  | 1308 | if (-e $inValue && ( ! -f _ || ! -r _)) | 
|  |  |  | 100 |  |  |  |  | 
| 74 |  |  |  |  |  |  | { | 
| 75 | 1 |  |  |  |  | 5 | return _illegalFilename | 
| 76 |  |  |  |  |  |  | } | 
| 77 |  |  |  |  |  |  |  | 
| 78 | 57 | 100 |  |  |  | 432 | $fh = new IO::File "<$inValue" | 
| 79 |  |  |  |  |  |  | or return _setError(undef, undef, "cannot open file '$inValue': $!"); | 
| 80 |  |  |  |  |  |  | } | 
| 81 |  |  |  |  |  |  | elsif( $inType eq 'buffer' || $inType eq 'handle') | 
| 82 |  |  |  |  |  |  | { | 
| 83 | 28 |  |  |  |  | 62 | $fh = $inValue; | 
| 84 |  |  |  |  |  |  | } | 
| 85 |  |  |  |  |  |  | else | 
| 86 |  |  |  |  |  |  | { | 
| 87 | 0 |  |  |  |  | 0 | return _illegalFilename | 
| 88 |  |  |  |  |  |  | } | 
| 89 |  |  |  |  |  |  |  | 
| 90 | 84 |  |  |  |  | 3627 | my %obj ; | 
| 91 |  |  |  |  |  |  | # my $inner = IO::Compress::Base::Common::createSelfTiedObject($class, \$StreamedUnzipError); | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | # # *$inner->{Pause} = 1; | 
| 94 |  |  |  |  |  |  | # $inner->_create(undef, 0, $fh, @_) | 
| 95 |  |  |  |  |  |  | #     or return undef; | 
| 96 |  |  |  |  |  |  |  | 
| 97 | 84 |  |  |  |  | 432 | my $inner = IO::Uncompress::Unzip->new($fh) ; | 
| 98 |  |  |  |  |  |  |  | 
| 99 | 84 |  |  |  |  | 88002 | $obj{Inner} = $inner; | 
| 100 | 84 |  |  |  |  | 156 | $obj{Open} = 1 ; | 
| 101 | 84 |  |  |  |  | 116 | $obj{FirstOne} = 1 ; | 
| 102 |  |  |  |  |  |  |  | 
| 103 | 84 |  |  |  |  | 369 | bless \%obj, $class; | 
| 104 |  |  |  |  |  |  | } | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | sub close | 
| 107 |  |  |  |  |  |  | { | 
| 108 | 84 |  |  | 84 | 1 | 13990 | my $self = shift; | 
| 109 |  |  |  |  |  |  | # TODO - fix me | 
| 110 | 84 |  |  |  |  | 315 | $self->{Inner}->close(); | 
| 111 | 84 |  |  |  |  | 2224 | return 1; | 
| 112 |  |  |  |  |  |  | } | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | sub DESTROY | 
| 115 |  |  |  |  |  |  | { | 
| 116 | 84 |  |  | 84 |  | 13562 | my $self = shift; | 
| 117 |  |  |  |  |  |  | } | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | sub next | 
| 120 |  |  |  |  |  |  | { | 
| 121 | 504 |  |  | 504 | 1 | 67870 | my $self = shift; | 
| 122 |  |  |  |  |  |  |  | 
| 123 | 504 | 100 |  |  |  | 949 | if ($self->{FirstOne}) | 
| 124 |  |  |  |  |  |  | { | 
| 125 | 84 |  |  |  |  | 105 | $self->{FirstOne} = 0; | 
| 126 |  |  |  |  |  |  | } | 
| 127 |  |  |  |  |  |  | else | 
| 128 |  |  |  |  |  |  | { | 
| 129 | 420 |  |  |  |  | 1068 | my $status = $self->{Inner}->nextStream(); | 
| 130 |  |  |  |  |  |  | return undef | 
| 131 | 420 | 100 |  |  |  | 166422 | if $status <= 0; | 
| 132 |  |  |  |  |  |  | } | 
| 133 |  |  |  |  |  |  |  | 
| 134 | 420 |  |  |  |  | 522 | my %member ; | 
| 135 | 420 |  |  |  |  | 689 | $member{Inner}  = $self->{Inner}; | 
| 136 |  |  |  |  |  |  | # $member{Member} = $member; | 
| 137 | 420 |  |  |  |  | 966 | $member{Info} = $self->{Inner}->getHeaderInfo() ; | 
| 138 |  |  |  |  |  |  | #Scalar::Util::weaken $member{Inner}; # for 5.8 | 
| 139 |  |  |  |  |  |  |  | 
| 140 | 420 |  |  |  |  | 3008 | return bless \%member, 'Archive::Zip::StreamedUnzip::Member'; | 
| 141 |  |  |  |  |  |  | } | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  | sub member | 
| 144 |  |  |  |  |  |  | { | 
| 145 | 0 |  |  | 0 | 0 | 0 | my $self = shift; | 
| 146 | 0 |  |  |  |  | 0 | my $name = shift; | 
| 147 |  |  |  |  |  |  |  | 
| 148 | 0 | 0 |  |  |  | 0 | return _setError(undef, undef, "Member '$name' not in zip") | 
| 149 |  |  |  |  |  |  | if ! defined $name ; | 
| 150 |  |  |  |  |  |  |  | 
| 151 | 0 |  |  |  |  | 0 | while (my $member = $self->next()) | 
| 152 |  |  |  |  |  |  | { | 
| 153 | 0 | 0 |  |  |  | 0 | return $member | 
| 154 |  |  |  |  |  |  | if $member->name() eq $name ; | 
| 155 |  |  |  |  |  |  |  | 
| 156 |  |  |  |  |  |  | } | 
| 157 |  |  |  |  |  |  |  | 
| 158 | 0 |  |  |  |  | 0 | return _setError(undef, undef, "Member '$name' not in zip") ; | 
| 159 |  |  |  |  |  |  | } | 
| 160 |  |  |  |  |  |  |  | 
| 161 |  |  |  |  |  |  | sub getExtraParams | 
| 162 |  |  |  |  |  |  | { | 
| 163 |  |  |  |  |  |  |  | 
| 164 |  |  |  |  |  |  | return ( | 
| 165 |  |  |  |  |  |  | # Zip header fields | 
| 166 | 0 |  |  | 0 | 0 | 0 | 'name'    => [IO::Compress::Base::Common::Parse_any,       undef], | 
| 167 |  |  |  |  |  |  |  | 
| 168 |  |  |  |  |  |  | #            'stream'  => [IO::Compress::Base::Common::Parse_boolean,   1], | 
| 169 |  |  |  |  |  |  | ); | 
| 170 |  |  |  |  |  |  | } | 
| 171 |  |  |  |  |  |  |  | 
| 172 |  |  |  |  |  |  | sub ckParams | 
| 173 |  |  |  |  |  |  | { | 
| 174 | 0 |  |  | 0 | 0 | 0 | my $self = shift ; | 
| 175 | 0 |  |  |  |  | 0 | my $got = shift ; | 
| 176 |  |  |  |  |  |  |  | 
| 177 |  |  |  |  |  |  | # unzip always needs crc32 | 
| 178 | 0 |  |  |  |  | 0 | $got->setValue('crc32' => 1); | 
| 179 |  |  |  |  |  |  |  | 
| 180 | 0 |  |  |  |  | 0 | *$self->{UnzipData}{Name} = $got->getValue('name'); | 
| 181 |  |  |  |  |  |  |  | 
| 182 | 0 |  |  |  |  | 0 | return 1; | 
| 183 |  |  |  |  |  |  | } | 
| 184 |  |  |  |  |  |  |  | 
| 185 |  |  |  |  |  |  |  | 
| 186 |  |  |  |  |  |  |  | 
| 187 |  |  |  |  |  |  |  | 
| 188 |  |  |  |  |  |  | { | 
| 189 |  |  |  |  |  |  | package Archive::Zip::StreamedUnzip::Member; | 
| 190 |  |  |  |  |  |  |  | 
| 191 |  |  |  |  |  |  | sub name | 
| 192 |  |  |  |  |  |  | { | 
| 193 | 420 |  |  | 420 |  | 77784 | my $self = shift; | 
| 194 |  |  |  |  |  |  | #        $self->_stdPreq() or return 0 ; | 
| 195 |  |  |  |  |  |  |  | 
| 196 | 420 |  |  |  |  | 2088 | return $self->{Info}{Name}; | 
| 197 |  |  |  |  |  |  | } | 
| 198 |  |  |  |  |  |  |  | 
| 199 |  |  |  |  |  |  | sub isDirectory | 
| 200 |  |  |  |  |  |  | { | 
| 201 | 420 |  |  | 420 |  | 459 | my $self = shift; | 
| 202 |  |  |  |  |  |  | #        $self->_stdPreq() or return 0 ; | 
| 203 |  |  |  |  |  |  |  | 
| 204 | 420 |  |  |  |  | 2561 | return substr($self->{Info}{Name}, -1, 1) eq '/' ; | 
| 205 |  |  |  |  |  |  | } | 
| 206 |  |  |  |  |  |  |  | 
| 207 |  |  |  |  |  |  | sub isFile | 
| 208 |  |  |  |  |  |  | { | 
| 209 | 336 |  |  | 336 |  | 360 | my $self = shift; | 
| 210 |  |  |  |  |  |  | #        $self->_stdPreq() or return 0 ; | 
| 211 |  |  |  |  |  |  |  | 
| 212 |  |  |  |  |  |  | # TODO - test for symlink | 
| 213 | 336 |  |  |  |  | 504 | return ! $self->isDirectory() ; | 
| 214 |  |  |  |  |  |  | } | 
| 215 |  |  |  |  |  |  |  | 
| 216 |  |  |  |  |  |  | sub isEncrypted | 
| 217 |  |  |  |  |  |  | { | 
| 218 | 0 |  |  | 0 |  | 0 | my $self = shift; | 
| 219 | 0 |  |  |  |  | 0 | return $self->{Info}{Encrypted}; | 
| 220 |  |  |  |  |  |  | # my $gpFlag = unpack ("v", substr($self->{Info}{Header}, 4 + 2, 2)); | 
| 221 |  |  |  |  |  |  | # return $gpFlag & (0x01 | (1 << 6)) ; | 
| 222 |  |  |  |  |  |  | } | 
| 223 |  |  |  |  |  |  |  | 
| 224 |  |  |  |  |  |  | # TODO | 
| 225 |  |  |  |  |  |  | # | 
| 226 |  |  |  |  |  |  | #    isZip64 | 
| 227 |  |  |  |  |  |  | #    isDir | 
| 228 |  |  |  |  |  |  | #    isSymLink | 
| 229 |  |  |  |  |  |  | #    isText | 
| 230 |  |  |  |  |  |  | #    isBinary | 
| 231 |  |  |  |  |  |  | #    isEncrypted | 
| 232 |  |  |  |  |  |  | #    isStreamed | 
| 233 |  |  |  |  |  |  | #    getComment | 
| 234 |  |  |  |  |  |  | #    getExtra | 
| 235 |  |  |  |  |  |  | #    compressedSize - 64 bit alert | 
| 236 |  |  |  |  |  |  | #    uncompressedSize | 
| 237 |  |  |  |  |  |  | #    time | 
| 238 |  |  |  |  |  |  | #    isStored | 
| 239 |  |  |  |  |  |  | #    compressionName | 
| 240 |  |  |  |  |  |  | # | 
| 241 |  |  |  |  |  |  | #   extractToFile | 
| 242 |  |  |  |  |  |  |  | 
| 243 |  |  |  |  |  |  | sub compressedSize | 
| 244 |  |  |  |  |  |  | { | 
| 245 | 0 |  |  | 0 |  | 0 | my $self = shift; | 
| 246 |  |  |  |  |  |  | #        $self->_stdPreq() or return 0 ; | 
| 247 |  |  |  |  |  |  |  | 
| 248 | 0 |  |  |  |  | 0 | my $CompressedLength = $self->{Info}{CompressedLength}; | 
| 249 | 0 | 0 |  |  |  | 0 | if (ref $CompressedLength) | 
| 250 |  |  |  |  |  |  | { | 
| 251 | 0 |  |  |  |  | 0 | return U64::get64bit($CompressedLength) | 
| 252 |  |  |  |  |  |  | } | 
| 253 | 0 |  |  |  |  | 0 | return $CompressedLength; | 
| 254 |  |  |  |  |  |  | } | 
| 255 |  |  |  |  |  |  |  | 
| 256 |  |  |  |  |  |  | sub uncompressedSize | 
| 257 |  |  |  |  |  |  | { | 
| 258 | 0 |  |  | 0 |  | 0 | my $self = shift; | 
| 259 |  |  |  |  |  |  | #        $self->_stdPreq() or return 0 ; | 
| 260 | 0 |  |  |  |  | 0 | my $UncompressedLength = $self->{Info}{UncompressedLength}; | 
| 261 | 0 | 0 |  |  |  | 0 | if (ref $UncompressedLength) | 
| 262 |  |  |  |  |  |  | { | 
| 263 | 0 |  |  |  |  | 0 | return U64::get64bit($UncompressedLength) | 
| 264 |  |  |  |  |  |  | } | 
| 265 | 0 |  |  |  |  | 0 | return $UncompressedLength; | 
| 266 |  |  |  |  |  |  | } | 
| 267 |  |  |  |  |  |  |  | 
| 268 |  |  |  |  |  |  | sub content | 
| 269 |  |  |  |  |  |  | { | 
| 270 | 252 |  |  | 252 |  | 380 | my $self = shift; | 
| 271 | 252 |  |  |  |  | 255 | my $data ; | 
| 272 |  |  |  |  |  |  |  | 
| 273 |  |  |  |  |  |  | # $self->{Inner}->read($data, $self->{UncompressedLength}); | 
| 274 | 252 |  |  |  |  | 841 | $self->{Inner}->read($data, $self->{Info}{UncompressedLength}); | 
| 275 |  |  |  |  |  |  |  | 
| 276 | 252 |  |  |  |  | 134214 | return $data; | 
| 277 |  |  |  |  |  |  | } | 
| 278 |  |  |  |  |  |  |  | 
| 279 |  |  |  |  |  |  | sub open | 
| 280 |  |  |  |  |  |  | { | 
| 281 | 168 |  |  | 168 |  | 271 | my $self = shift; | 
| 282 |  |  |  |  |  |  |  | 
| 283 |  |  |  |  |  |  | #        return  return $self->{Inner} ; | 
| 284 |  |  |  |  |  |  |  | 
| 285 |  |  |  |  |  |  | #        my $handle = Symbol::gensym(); | 
| 286 |  |  |  |  |  |  | #        tie *$handle, "Archive::Zip::StreamedUnzip::Handle", $self->{SZ}{UnZip}; | 
| 287 |  |  |  |  |  |  | #        return $handle; | 
| 288 |  |  |  |  |  |  |  | 
| 289 | 168 |  |  |  |  | 465 | my $z = IO::Compress::Base::Common::createSelfTiedObject("Archive::Zip::StreamedUnzip::Handle", \$StreamedUnzipError) ; | 
| 290 |  |  |  |  |  |  |  | 
| 291 | 168 |  |  |  |  | 1583 | *$z->{Open} = 1 ; | 
| 292 | 168 |  |  |  |  | 250 | *$z->{SZ} = $self->{Inner}; | 
| 293 | 168 |  |  |  |  | 531 | Scalar::Util::weaken *$z->{SZ}; # for 5.8 | 
| 294 |  |  |  |  |  |  |  | 
| 295 | 168 |  |  |  |  | 244 | $z; | 
| 296 |  |  |  |  |  |  | } | 
| 297 |  |  |  |  |  |  |  | 
| 298 |  |  |  |  |  |  | sub close | 
| 299 |  |  |  |  |  |  | { | 
| 300 | 84 |  |  | 84 |  | 138 | my $self = shift; | 
| 301 | 84 |  |  |  |  | 197 | return 1; | 
| 302 |  |  |  |  |  |  | } | 
| 303 |  |  |  |  |  |  |  | 
| 304 |  |  |  |  |  |  |  | 
| 305 |  |  |  |  |  |  | } | 
| 306 |  |  |  |  |  |  |  | 
| 307 |  |  |  |  |  |  |  | 
| 308 |  |  |  |  |  |  | { | 
| 309 |  |  |  |  |  |  | package Archive::Zip::StreamedUnzip::Handle ; | 
| 310 |  |  |  |  |  |  |  | 
| 311 |  |  |  |  |  |  | sub TIEHANDLE | 
| 312 |  |  |  |  |  |  | { | 
| 313 | 168 | 50 |  | 168 |  | 4275 | return $_[0] if ref($_[0]); | 
| 314 | 0 |  |  |  |  | 0 | die "OOPS\n" ; | 
| 315 |  |  |  |  |  |  | } | 
| 316 |  |  |  |  |  |  |  | 
| 317 |  |  |  |  |  |  | sub UNTIE | 
| 318 |  |  |  |  |  |  | { | 
| 319 | 0 |  |  | 0 |  | 0 | my $self = shift ; | 
| 320 |  |  |  |  |  |  | } | 
| 321 |  |  |  |  |  |  |  | 
| 322 |  |  |  |  |  |  | sub DESTROY | 
| 323 |  |  |  |  |  |  | { | 
| 324 |  |  |  |  |  |  | #        print "DESTROY H"; | 
| 325 | 168 |  |  | 168 |  | 68289 | my $self = shift ; | 
| 326 | 168 |  |  |  |  | 886 | local ($., $@, $!, $^E, $?); | 
| 327 | 168 |  |  |  |  | 356 | $self->close() ; | 
| 328 |  |  |  |  |  |  |  | 
| 329 |  |  |  |  |  |  | # TODO - memory leak with 5.8.0 - this isn't called until | 
| 330 |  |  |  |  |  |  | #        global destruction | 
| 331 |  |  |  |  |  |  | # | 
| 332 | 168 |  |  |  |  | 173 | %{ *$self } = () ; | 
|  | 168 |  |  |  |  | 552 |  | 
| 333 | 168 |  |  |  |  | 1008 | undef $self ; | 
| 334 |  |  |  |  |  |  | } | 
| 335 |  |  |  |  |  |  |  | 
| 336 |  |  |  |  |  |  |  | 
| 337 |  |  |  |  |  |  | sub close | 
| 338 |  |  |  |  |  |  | { | 
| 339 | 168 |  |  | 168 |  | 206 | my $self = shift ; | 
| 340 | 168 | 50 |  |  |  | 464 | return 1 if ! *$self->{Open}; | 
| 341 |  |  |  |  |  |  |  | 
| 342 | 168 |  |  |  |  | 210 | *$self->{Open} = 0 ; | 
| 343 |  |  |  |  |  |  |  | 
| 344 |  |  |  |  |  |  | #        untie *$self | 
| 345 |  |  |  |  |  |  | #            if $] >= 5.008 ; | 
| 346 |  |  |  |  |  |  |  | 
| 347 | 168 | 50 |  |  |  | 321 | if (defined *$self->{SZ}) | 
| 348 |  |  |  |  |  |  | { | 
| 349 |  |  |  |  |  |  | #            *$self->{SZ}{Raw} = undef ; | 
| 350 | 168 |  |  |  |  | 255 | *$self->{SZ} = undef ; | 
| 351 |  |  |  |  |  |  | } | 
| 352 |  |  |  |  |  |  |  | 
| 353 | 168 |  |  |  |  | 190 | 1; | 
| 354 |  |  |  |  |  |  | } | 
| 355 |  |  |  |  |  |  |  | 
| 356 |  |  |  |  |  |  | sub read | 
| 357 |  |  |  |  |  |  | { | 
| 358 |  |  |  |  |  |  | # TODO - remember to fix the return value to match real read & not the broken one in IO::Uncompress | 
| 359 | 84 |  |  | 84 |  | 19102 | my $self = shift; | 
| 360 | 84 | 50 |  |  |  | 180 | $self->_stdPreq() or return 0 ; | 
| 361 |  |  |  |  |  |  |  | 
| 362 |  |  |  |  |  |  | #        warn "READ [$self]\n"; | 
| 363 |  |  |  |  |  |  | #        warn "READ [*$self->{SZ}]\n"; | 
| 364 |  |  |  |  |  |  |  | 
| 365 |  |  |  |  |  |  | #        $_[0] = *$self->{SZ}{Unzip}; | 
| 366 |  |  |  |  |  |  | #        my $status = goto &IO::Uncompress::Base::read; | 
| 367 |  |  |  |  |  |  | #        $_[0] = \$_[0] unless ref $_[0]; | 
| 368 | 84 |  |  |  |  | 269 | my $status = *$self->{SZ}->read(@_); | 
| 369 | 84 | 50 |  |  |  | 27274 | $status = undef if $status < 0 ; | 
| 370 | 84 |  |  |  |  | 258 | return $status; | 
| 371 |  |  |  |  |  |  | } | 
| 372 |  |  |  |  |  |  |  | 
| 373 |  |  |  |  |  |  | sub readline | 
| 374 |  |  |  |  |  |  | { | 
| 375 | 84 |  |  | 84 |  | 14304 | my $self = shift; | 
| 376 | 84 | 50 |  |  |  | 153 | $self->_stdPreq() or return 0 ; | 
| 377 | 84 |  |  |  |  | 343 | *$self->{SZ}->getline(@_); | 
| 378 |  |  |  |  |  |  | } | 
| 379 |  |  |  |  |  |  |  | 
| 380 |  |  |  |  |  |  | sub tell | 
| 381 |  |  |  |  |  |  | { | 
| 382 | 420 |  |  | 420 |  | 47152 | my $self = shift; | 
| 383 | 420 | 50 |  |  |  | 655 | $self->_stdPreq() or return 0 ; | 
| 384 |  |  |  |  |  |  |  | 
| 385 | 420 |  |  |  |  | 1363 | *$self->{SZ}->tell(@_); | 
| 386 |  |  |  |  |  |  | } | 
| 387 |  |  |  |  |  |  |  | 
| 388 |  |  |  |  |  |  | sub eof | 
| 389 |  |  |  |  |  |  | { | 
| 390 | 504 |  |  | 504 |  | 111840 | my $self = shift; | 
| 391 | 504 | 50 |  |  |  | 875 | $self->_stdPreq() or return 0 ; | 
| 392 |  |  |  |  |  |  |  | 
| 393 | 504 |  |  |  |  | 1403 | *$self->{SZ}->eof; | 
| 394 |  |  |  |  |  |  | } | 
| 395 |  |  |  |  |  |  |  | 
| 396 |  |  |  |  |  |  | sub _stdPreq | 
| 397 |  |  |  |  |  |  | { | 
| 398 | 1092 |  |  | 1092 |  | 1122 | my $self = shift; | 
| 399 |  |  |  |  |  |  |  | 
| 400 |  |  |  |  |  |  | # TODO - fix me | 
| 401 | 1092 |  |  |  |  | 2056 | return 1; | 
| 402 |  |  |  |  |  |  |  | 
| 403 |  |  |  |  |  |  | return _setError("Zip file closed") | 
| 404 | 0 | 0 | 0 |  |  |  | if ! defined defined *$self->{SZ} || ! *$self->{Inner}{Open} ; | 
| 405 |  |  |  |  |  |  |  | 
| 406 |  |  |  |  |  |  |  | 
| 407 |  |  |  |  |  |  | return _setError("member filehandle closed") | 
| 408 | 0 | 0 |  |  |  |  | if  ! *$self->{Open} ; #|| ! defined *$self->{SZ}{Raw}; | 
| 409 |  |  |  |  |  |  |  | 
| 410 |  |  |  |  |  |  | return 0 | 
| 411 | 0 | 0 |  |  |  |  | if *$self->{SZ}{Error} ; | 
| 412 |  |  |  |  |  |  |  | 
| 413 | 0 |  |  |  |  |  | return 1; | 
| 414 |  |  |  |  |  |  | } | 
| 415 |  |  |  |  |  |  |  | 
| 416 |  |  |  |  |  |  | sub _setError | 
| 417 |  |  |  |  |  |  | { | 
| 418 | 0 |  |  | 0 |  |  | $Archive::Zip::SimpleUnzip::StreamedUnzipError = $_[0] ; | 
| 419 | 0 |  |  |  |  |  | return 0; | 
| 420 |  |  |  |  |  |  | } | 
| 421 |  |  |  |  |  |  |  | 
| 422 |  |  |  |  |  |  | sub clearerr | 
| 423 |  |  |  |  |  |  | { | 
| 424 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 425 |  |  |  |  |  |  |  | 
| 426 | 0 |  |  |  |  |  | return 0; | 
| 427 |  |  |  |  |  |  | } | 
| 428 |  |  |  |  |  |  |  | 
| 429 | 0 |  |  | 0 |  |  | sub binmode { 1 } | 
| 430 |  |  |  |  |  |  |  | 
| 431 |  |  |  |  |  |  | #    sub clearerr { $Archive::Zip::SimpleUnzip::StreamedUnzipError = '' } | 
| 432 |  |  |  |  |  |  |  | 
| 433 |  |  |  |  |  |  | *BINMODE  = \&binmode; | 
| 434 |  |  |  |  |  |  | #    *SEEK     = \&seek; | 
| 435 |  |  |  |  |  |  | *READ     = \&read; | 
| 436 |  |  |  |  |  |  | *sysread  = \&read; | 
| 437 |  |  |  |  |  |  | *TELL     = \&tell; | 
| 438 |  |  |  |  |  |  | *READLINE = \&readline; | 
| 439 |  |  |  |  |  |  | *EOF      = \&eof; | 
| 440 |  |  |  |  |  |  | *FILENO   = \&fileno; | 
| 441 |  |  |  |  |  |  | *CLOSE    = \&close; | 
| 442 |  |  |  |  |  |  | } | 
| 443 |  |  |  |  |  |  |  | 
| 444 |  |  |  |  |  |  |  | 
| 445 |  |  |  |  |  |  | 1; | 
| 446 |  |  |  |  |  |  |  | 
| 447 |  |  |  |  |  |  | __END__ |