Archive-Zip

 view release on metacpan or  search on metacpan

lib/Archive/Zip.pm  view on Meta::CPAN

    my $member1 = $zip->removeMember( 'xyz' );
    my $member2 = $zip->replaceMember( 'abc', $member1 );
    # now, $member2 (named 'abc') is not in $zip,
    # and $member1 (named 'xyz') is, having taken $member2's place.

=item extractMember( $memberOrName [, $extractedName ] )

=item extractMember( { memberOrZipName => $memberOrName
    [, name => $extractedName ] } )

Extract the given member, or match its name and extract it.
Returns undef if member does not exist in this Zip. If
optional second arg is given, use it as the name of the
extracted member. Otherwise, the internal filename of the
member is used as the name of the extracted file or
directory.
If you pass C<$extractedName>, it should be in the local file
system's format.
If you do not pass C<$extractedName> and the internal filename traverses
a parent directory or a symbolic link, the extraction will be aborted with
C<AC_ERROR> for security reason.
All necessary directories will be created. Returns C<AZ_OK>
on success.

=item extractMemberWithoutPaths( $memberOrName [, $extractedName ] )

=item extractMemberWithoutPaths( { memberOrZipName => $memberOrName
    [, name => $extractedName ] } )

Extract the given member, or match its name and extract it.
Does not use path information (extracts into the current
directory). Returns undef if member does not exist in this
Zip.
If optional second arg is given, use it as the name of the
extracted member (its paths will be deleted too). Otherwise,
the internal filename of the member (minus paths) is used as
the name of the extracted file or directory. Returns C<AZ_OK>
on success.
If you do not pass C<$extractedName> and the internal filename is equalled
to a local symbolic link, the extraction will be aborted with C<AC_ERROR> for
security reason.

=item addMember( $member )

=item addMember( { member => $member } )

Append a member (possibly from another zip file) to the zip
file. Returns the new member. Generally, you will use
addFile(), addDirectory(), addFileOrDirectory(), addString(),
or read() to add members.

    # Move member named 'abc' to end of zip:
    my $member = $zip->removeMember( 'abc' );
    $zip->addMember( $member );

=item updateMember( $memberOrName, $fileName )

=item updateMember( { memberOrZipName => $memberOrName, name => $fileName } )

Update a single member from the file or directory named C<$fileName>.
Returns the (possibly added or updated) member, if any; C<undef> on
errors.
The comparison is based on C<lastModTime()> and (in the case of a
non-directory) the size of the file.

=item addFile( $fileName [, $newName, $compressionLevel ] )

=item addFile( { filename => $fileName
    [, zipName => $newName, compressionLevel => $compressionLevel } ] )

Append a member whose data comes from an external file,
returning the member or undef. The member will have its file
name set to the name of the external file, and its
desiredCompressionMethod set to COMPRESSION_DEFLATED. The
file attributes and last modification time will be set from
the file.
If the name given does not represent a readable plain file or
symbolic link, undef will be returned. C<$fileName> must be
in the format required for the local file system.
The optional C<$newName> argument sets the internal file name
to something different than the given $fileName. C<$newName>,
if given, must be in Zip name format (i.e. Unix).
The text mode bit will be set if the contents appears to be
text (as returned by the C<-T> perl operator).


I<NOTE> that you should not (generally) use absolute path names
in zip member names, as this will cause problems with some zip
tools as well as introduce a security hole and make the zip
harder to use.

=item addDirectory( $directoryName [, $fileName ] )

=item addDirectory( { directoryName => $directoryName
    [, zipName => $fileName ] } )


Append a member created from the given directory name. The
directory name does not have to name an existing directory.
If the named directory exists, the file modification time and
permissions are set from the existing directory, otherwise
they are set to now and permissive default permissions.
C<$directoryName> must be in local file system format.
The optional second argument sets the name of the archive
member (which defaults to C<$directoryName>). If given, it
must be in Zip (Unix) format.
Returns the new member.

=item addFileOrDirectory( $name [, $newName, $compressionLevel ] )

=item addFileOrDirectory( { name => $name [, zipName => $newName,
    compressionLevel => $compressionLevel ] } )


Append a member from the file or directory named $name. If
$newName is given, use it for the name of the new member.
Will add or remove trailing slashes from $newName as needed.
C<$name> must be in local file system format.
The optional second argument sets the name of the archive
member (which defaults to C<$name>). If given, it must be in
Zip (Unix) format.



( run in 0.791 second using v1.01-cache-2.11-cpan-99c4e6809bf )