1 package Archive
::Zip
::StringMember
;
4 use vars
qw( $VERSION @ISA );
8 @ISA = qw( Archive::Zip::Member );
16 # Create a new string member. Default is COMPRESSION_STORED.
17 # Can take a ref to a string as well.
23 $name = Encode
::encode
( 'cp437', $name );
24 my $self = $class->new(@_);
25 $self->contents($string);
26 $self->fileName($name) if defined($name);
28 # Set the file date to now
29 $self->setLastModFileDateTimeFromUnix( time() );
30 $self->unixFileAttributes( $self->DEFAULT_FILE_PERMISSIONS );
37 return $self if ref($self) eq $newClass;
38 delete( $self->{'contents'} );
39 return $self->SUPER::_become
($newClass);
42 # Get or set my contents. Note that we do not call the superclass
43 # version of this, because it calls us.
47 if ( defined($string) ) {
49 pack( 'C0a*', ( ref($string) eq 'SCALAR' ) ?
$$string : $string );
50 $self->{'uncompressedSize'} = $self->{'compressedSize'} =
51 length( $self->{'contents'} );
52 $self->{'compressionMethod'} = COMPRESSION_STORED
;
54 return $self->{'contents'};
57 # Return bytes read. Note that first parameter is a ref to a buffer.
59 # my ( $bytesRead, $status) = $self->readRawChunk( \$data, $chunkSize );
61 my ( $self, $dataRef, $chunkSize ) = @_;
62 $$dataRef = substr( $self->contents(), $self->_readOffset(), $chunkSize );
63 return ( length($$dataRef), AZ_OK
);