| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Archive::Zip::StringMember; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 28 |  |  | 28 |  | 159 | use strict; | 
|  | 28 |  |  |  |  | 60 |  | 
|  | 28 |  |  |  |  | 762 |  | 
| 4 | 28 |  |  | 28 |  | 122 | use vars qw( $VERSION @ISA ); | 
|  | 28 |  |  |  |  | 45 |  | 
|  | 28 |  |  |  |  | 1332 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | BEGIN { | 
| 7 | 28 |  |  | 28 |  | 88 | $VERSION = '1.67'; | 
| 8 | 28 |  |  |  |  | 1022 | @ISA     = qw( Archive::Zip::Member ); | 
| 9 |  |  |  |  |  |  | } | 
| 10 |  |  |  |  |  |  |  | 
| 11 | 28 |  |  |  |  | 10671 | use Archive::Zip qw( | 
| 12 |  |  |  |  |  |  | :CONSTANTS | 
| 13 |  |  |  |  |  |  | :ERROR_CODES | 
| 14 | 28 |  |  | 28 |  | 153 | ); | 
|  | 28 |  |  |  |  | 42 |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | # Create a new string member. Default is COMPRESSION_STORED. | 
| 17 |  |  |  |  |  |  | # Can take a ref to a string as well. | 
| 18 |  |  |  |  |  |  | sub _newFromString { | 
| 19 | 15 |  |  | 15 |  | 53 | my $class  = shift; | 
| 20 | 15 |  |  |  |  | 32 | my $string = shift; | 
| 21 | 15 |  |  |  |  | 27 | my $name   = shift; | 
| 22 | 15 |  |  |  |  | 109 | my $self   = $class->new(@_); | 
| 23 | 15 |  |  |  |  | 64 | $self->contents($string); | 
| 24 | 15 | 100 |  |  |  | 92 | $self->fileName($name) if defined($name); | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | # Set the file date to now | 
| 27 | 15 |  |  |  |  | 82 | $self->setLastModFileDateTimeFromUnix(time()); | 
| 28 | 15 |  |  |  |  | 74 | $self->unixFileAttributes($self->DEFAULT_FILE_PERMISSIONS); | 
| 29 | 15 |  |  |  |  | 41 | return $self; | 
| 30 |  |  |  |  |  |  | } | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | sub _become { | 
| 33 | 0 |  |  | 0 |  | 0 | my $self     = shift; | 
| 34 | 0 |  |  |  |  | 0 | my $newClass = shift; | 
| 35 | 0 | 0 |  |  |  | 0 | return $self if ref($self) eq $newClass; | 
| 36 | 0 |  |  |  |  | 0 | delete($self->{'contents'}); | 
| 37 | 0 |  |  |  |  | 0 | return $self->SUPER::_become($newClass); | 
| 38 |  |  |  |  |  |  | } | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | # Get or set my contents. Note that we do not call the superclass | 
| 41 |  |  |  |  |  |  | # version of this, because it calls us. | 
| 42 |  |  |  |  |  |  | sub contents { | 
| 43 | 118 |  |  | 118 | 1 | 20622 | my $self   = shift; | 
| 44 | 118 |  |  |  |  | 193 | my $string = shift; | 
| 45 | 118 | 100 |  |  |  | 256 | if (defined($string)) { | 
| 46 | 24 | 50 |  |  |  | 299 | $self->{'contents'} = | 
| 47 |  |  |  |  |  |  | pack('C0a*', (ref($string) eq 'SCALAR') ? $$string : $string); | 
| 48 |  |  |  |  |  |  | $self->{'uncompressedSize'} = $self->{'compressedSize'} = | 
| 49 | 24 |  |  |  |  | 88 | length($self->{'contents'}); | 
| 50 | 24 |  |  |  |  | 52 | $self->{'compressionMethod'} = COMPRESSION_STORED; | 
| 51 |  |  |  |  |  |  | } | 
| 52 | 118 | 100 |  |  |  | 448 | return wantarray ? ($self->{'contents'}, AZ_OK) : $self->{'contents'}; | 
| 53 |  |  |  |  |  |  | } | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | # Return bytes read. Note that first parameter is a ref to a buffer. | 
| 56 |  |  |  |  |  |  | # my $data; | 
| 57 |  |  |  |  |  |  | # my ( $bytesRead, $status) = $self->readRawChunk( \$data, $chunkSize ); | 
| 58 |  |  |  |  |  |  | sub _readRawChunk { | 
| 59 | 88 |  |  | 88 |  | 264 | my ($self, $dataRef, $chunkSize) = @_; | 
| 60 | 88 |  |  |  |  | 226 | $$dataRef = substr($self->contents(), $self->_readOffset(), $chunkSize); | 
| 61 | 88 |  |  |  |  | 244 | return (length($$dataRef), AZ_OK); | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | 1; |