Archive-Extract
view release on metacpan or search on metacpan
lib/Archive/Extract.pm view on Meta::CPAN
### set $Archive::Extract::WARN to 0 to disable printing
### of errors
if( $WARN ) {
carp $DEBUG ? $lerror : $error;
}
return;
}
sub error {
my $self = shift;
### make sure we have a fallback aref
my $aref = do {
shift()
? $self->_error_msg_long
: $self->_error_msg
} || [];
return join $/, @$aref;
}
=head2 debug( MESSAGE )
This method outputs MESSAGE to the default filehandle if C<$DEBUG> is
true. It's a small method, but it's here if you'd like to subclass it
so you can so something else with any debugging output.
=cut
### this is really a stub for subclassing
sub debug {
return unless $DEBUG;
print $_[1];
}
sub _no_buffer_files {
my $self = shift;
my $file = shift or return;
return loc("No buffer captured, unable to tell ".
"extracted files or extraction dir for '%1'", $file);
}
sub _no_buffer_content {
my $self = shift;
my $file = shift or return;
return loc("No buffer captured, unable to get content for '%1'", $file);
}
1;
=pod
=head1 UTILITY FUNCTION
=head2 type_for($archive)
Given an archive file name, it determins the type by parsing the file
name extension. Used by C<new()> when the C<type> parameter is not passed.
Also useful when the archive file does not include a suffix but the file
name is otherwise known, such as when a file is uploaded to a web server
and stored with a temporary name that differs from the original name, and
you want to use the same detection pattern as Archive::Extract. Example:
my $ae = Archive::Extract->new(
archive => '/tmp/02af6s',
type => Archive::Extract::type_for('archive.zip'),
);
=head1 HOW IT WORKS
C<Archive::Extract> tries first to determine what type of archive you
are passing it, by inspecting its suffix. It does not do this by using
Mime magic, or something related. See C<CAVEATS> below.
Once it has determined the file type, it knows which extraction methods
it can use on the archive. It will try a perl solution first, then fall
back to a commandline tool if that fails. If that also fails, it will
return false, indicating it was unable to extract the archive.
See the section on C<GLOBAL VARIABLES> to see how to alter this order.
=head1 CAVEATS
=head2 File Extensions
C<Archive::Extract> trusts on the extension of the archive to determine
what type it is, and what extractor methods therefore can be used. If
your archives do not have any of the extensions as described in the
C<new()> method, you will have to specify the type explicitly, or
C<Archive::Extract> will not be able to extract the archive for you.
=head2 Supporting Very Large Files
C<Archive::Extract> can use either pure perl modules or command line
programs under the hood. Some of the pure perl modules (like
C<Archive::Tar> and Compress::unLZMA) take the entire contents of the archive into memory,
which may not be feasible on your system. Consider setting the global
variable C<$Archive::Extract::PREFER_BIN> to C<1>, which will prefer
the use of command line programs and won't consume so much memory.
See the C<GLOBAL VARIABLES> section below for details.
=head2 Bunzip2 support of arbitrary extensions.
Older versions of C</bin/bunzip2> do not support arbitrary file
extensions and insist on a C<.bz2> suffix. Although we do our best
to guard against this, if you experience a bunzip2 error, it may
be related to this. For details, please see the C<have_old_bunzip2>
method.
=head1 GLOBAL VARIABLES
=head2 $Archive::Extract::DEBUG
Set this variable to C<true> to have all calls to command line tools
be printed out, including all their output.
This also enables C<Carp::longmess> errors, instead of the regular
C<carp> errors.
Good for tracking down why things don't work with your particular
setup.
( run in 0.855 second using v1.01-cache-2.11-cpan-b16cb0d3907 )