summaryrefslogtreecommitdiff
path: root/lib/SlackBuild/Archive/Extractor.pm
blob: de489622e33d95f79c4fa83043845f6fe43b3ba8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package SlackBuild::Archive::Extractor;
use Carp;
use SlackBuild::Archive::Extractor::HTTP;
use SlackBuild::Archive::Extractor::Tar;

sub new {
    croak "bad number of arguments" unless @_ == 4;
    my ($class, $archive, $file, $destdir) = @_;
    return bless { _archive => $archive,
		   _tempfile => $file,
		   _destdir => $destdir }, $class;
}

sub logger {
    my $self = shift;
    $self->{_logger} //= Log::Log4perl::get_logger(ref($self))
}

sub backend {
    my ($class, $download, @args) = @_;
    if ($download->is_html) {
	return new SlackBuild::Archive::Extractor::HTTP($download, @args);
    } else {
	return new SlackBuild::Archive::Extractor::Tar($download, @args);
    }
}

sub archive  { shift->{_archive} }
sub destdir  { shift->{_destdir} }
sub tempfile { shift->{_tempfile} }
sub rewind { seek shift->tempfile, 0, 0 }

sub extract {
    my $self = shift;
    $self->logger->error('unrecognized download format');
    return new SlackBuild::Download($self)
}

1;

Return to:

Send suggestions and report system problems to the System administrator.