summaryrefslogtreecommitdiff
path: root/lib/SlackBuild/Archive/Extractor.pm
blob: 15ed76f4b57108026257c9540d6543ad6372f5e5 (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
40
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 backend {
    my ($class, $archive, @args) = @_;
    if ($archive->downloaded_html) {
	return new SlackBuild::Archive::Extractor::HTTP($archive, @args);
    } else {
	return new SlackBuild::Archive::Extractor::Tar($archive, @args);
    }
}

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

sub error {
    my $self = shift;
    return $self->archive->error(@_);
}

sub success { shift->archive->download_status }

sub extract {
    my $self = shift;
    return $self->archive->error('unrecognized download format');
}

1;

Return to:

Send suggestions and report system problems to the System administrator.