Archive-Tar-Wrapper
view release on metacpan or search on metacpan
lib/Archive/Tar/Wrapper.pm view on Meta::CPAN
tar cfv tarfile -T filelist
where C<filelist> is a file containing all file to be added. The default
for this switch is 512, but it can be changed by setting the parameter
C<max_cmd_line_args>:
my $arch = Archive::Tar::Wrapper->new(
max_cmd_line_args => 1024
);
The allowable parameters are:
=over
=item *
C<tar>
=item *
C<tmpdir>
=item *
C<tar_read_options>
=item *
C<tar_write_options>
=item *
C<tar_gnu_read_options>
=item *
C<tar_gnu_write_options>
=item *
C<max_cmd_line_args>: defaults to 512
=item *
C<ramdisk>
=back
Returns a new instance of the class.
=head2 read
$arch->read("archive.tgz");
C<read()> opens the given tarball, expands it into a temporary directory
and returns 1 on success or C<undef> on failure.
The temporary directory holding the tar data gets cleaned up when C<$arch>
goes out of scope.
C<read> handles both compressed and uncompressed files. To find out if
a file is compressed or uncompressed, it tries to guess by extension,
then by checking the first couple of bytes in the tar file.
If only a limited number of files is needed from a tarball, they
can be specified after the tarball name:
$arch->read("archive.tgz", "path/file.dat", "path/sub/another.txt");
The file names are passed unmodified to the C<tar> command, make sure
that the file paths match exactly what's in the tarball, otherwise
C<read()> will fail.
=head2 list_reset
$arch->list_reset()
Resets the list iterator. To be used before the first call to C<list_next()>.
=head2 tardir
$arch->tardir();
Return the directory the tarball was unpacked in. This is sometimes useful
to play dirty tricks on B<Archive::Tar::Wrapper> by mass-manipulating
unpacked files before wrapping them back up into the tarball.
=head2 is_compressed
Returns a string to identify if the tarball is compressed or not.
Expect as parameter a string with the path to the tarball.
Returns:
=over
=item *
a "z" character if the file is compressed with C<gzip>.
=item *
a "j" character if the file is compressed with C<bzip2>.
=item *
a "" character if the file is not compressed at all.
=back
=head2 locate
$arch->locate($logic_path);
Finds the physical location of a file, specified by C<$logic_path>, which
is the virtual path of the file within the tarball. Returns a path to
the temporary file B<Archive::Tar::Wrapper> created to manipulate the
tarball on disk.
=head2 add
( run in 1.421 second using v1.01-cache-2.11-cpan-d8267643d1d )