The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Archive::SevenZip - Read/write 7z , zip , ISO9960 and other archives

SYNOPSIS

  my $ar = Archive::SevenZip->new(
      find => 1,
      archivename => $archivename,
      verbose => $verbose,
  );

  for my $entry ( $ar->list ) {
      my $target = join "/", "$target_dir", $entry->basename;
      $ar->extractMember( $entry->fileName, $target );
  };

METHODS

Archive::SevenZip->find_7z_executable

Finds the 7z executable in the path or in $ENV{ProgramFiles} or $ENV{ProgramFiles(x86)}. This is called when a Archive::SevenZip instance is created with the find parameter set to 1.

Archive::SevenZip->new

  my $ar = Archive::SevenZip->new( $archivename );

  my $ar = Archive::SevenZip->new(
      archivename => $archivename,
      find => 1,
  );

Creates a new class instance.

find - will search $ENV{PATH},

$ar->open

  my @entries = $ar->open;
  for my $entry (@entries) {
      print $entry->name, "\n";
  };

Lists the entries in the archive. A fresh archive which does not exist on disk yet has no entries. The returned entries are Archive::SevenZip::Entry instances.

This method will one day move to the Path::Class-compatibility API.

$ar->memberNamed

  my $entry = $ar->memberNamed('hello_world.txt');
  print $entry->fileName, "\n";

The path separator must be a forward slash ("/")

This method will one day move to the Archive::Zip-compatibility API.

$ar->openMemberFH

  my $fh = $ar->openMemberFH('test.txt');
  while( <$fh> ) {
      print "test.txt: $_";
  };

Reads the uncompressed content of the member from the archive.

This method will one day move to the Archive::Zip-compatibility API.

$ar->extractMember

  $ar->extractMember('test.txt' => 'extracted_test.txt');

Extracts the uncompressed content of the member from the archive.

This method will one day move to the Archive::Zip-compatibility API.

$ar->removeMember

  $ar->removeMember('test.txt');

Removes the member from the archive.

->add_scalar

    $ar->add_scalar( "Some name.txt", "This is the content" );

Adds a scalar as an archive member.

Unfortunately, 7zip doesn't reliably read archive members from STDIN, so the scalar will be written to a tempfile, added to the archive and then renamed in the archive.

This requires 7zip version 9.30+

->add_directory

    $ar->add_directory( "real_etc", "etc" );

Adds an empty directory

This currently ignores the directory date and time if the directory exists

NAME

Path::Class::Archive - treat archives as directories

CAUTION

This module tries to mimic the API of Archive::Zip in some cases and in other cases, the API of Path::Class. It is also a very rough draft that just happens to be doing what I need, mostly extracting files.

REPOSITORY

The public repository of this module is http://github.com/Corion/archive-sevenzip.

SUPPORT

The public support forum of this module is https://perlmonks.org/.

BUG TRACKER

Please report bugs in this module via the RT CPAN bug queue at https://rt.cpan.org/Public/Dist/Display.html?Name=Archive-SevenZip or via mail to archive-sevenzip-Bugs@rt.cpan.org.

AUTHOR

Max Maischein corion@cpan.org

COPYRIGHT (c)

Copyright 2015-2016 by Max Maischein corion@cpan.org.

LICENSE

This module is released under the same terms as Perl itself.