#!/usr/bin/perl -w
BEGIN {
if
(-d
't'
) {
push
@INC
,
't'
;
}
}
my
$test_data_dir
= get_test_data_dir();
my
$test_data_no
=
'tc2'
;
my
$map
= {};
my
$probe
= Archive::Probe->new();
SKIP: {
skip
"unrar is not installed"
, 5
unless
$probe
->_is_cmd_avail(
'unrar'
);
skip
"unzip is not installed"
, 5
unless
$probe
->_is_cmd_avail(
'unzip'
);
skip
"7za is not installed"
, 5
unless
$probe
->_is_cmd_avail(
'7za'
);
skip
"tar is not installed"
, 5
unless
$probe
->_is_cmd_avail(
'tar'
);
my
$tmpdir
= tempdir(
'_arXXXXXXXX'
,
DIR
=> File::Spec->tmpdir());
my
$base
= catdir(
$test_data_dir
,
$test_data_no
);
my
$ver_abc
= catfile(
$tmpdir
,
'version.abc'
);
my
$b_tgz
= catfile(
$tmpdir
,
'b.tgz'
);
my
$c_bz2
= catfile(
$tmpdir
,
'c.bz2'
);
my
$d_zip
= catfile(
$tmpdir
,
'd.zip'
);
my
$e_7z
= catfile(
$tmpdir
,
'e.7z'
);
my
$dir_txt
= catfile(
$tmpdir
,
'dir.txt'
);
my
$ret
=
$probe
->extract(
$base
,
$tmpdir
, 0, 1);
ok(
$ret
&&
-f
$dir_txt
&&
-f
$b_tgz
&&
!-f
$c_bz2
&&
!-f
$d_zip
&&
!-f
$e_7z
&&
!-f
$ver_abc
,
'Flat non-recurisve extract deep nested archive(starts w/ dir)'
);
rmtree(
$tmpdir
);
$tmpdir
= tempdir(
'_arXXXXXXXX'
,
DIR
=> File::Spec->tmpdir());
$ver_abc
= catfile(
$tmpdir
,
'version.abc'
);
$b_tgz
= catfile(
$tmpdir
,
'b.tgz'
);
$c_bz2
= catfile(
$tmpdir
,
'c.bz2'
);
$d_zip
= catfile(
$tmpdir
,
'd.zip'
);
$e_7z
= catfile(
$tmpdir
,
'e.7z'
);
$dir_txt
= catfile(
$tmpdir
,
'dir.txt'
);
$ret
=
$probe
->extract(
$base
,
$tmpdir
, 1, 1);
ok(
$ret
&&
-f
$dir_txt
&&
-f
$b_tgz
&&
-f
$c_bz2
&&
-f
$d_zip
&&
-f
$e_7z
&&
-f
$ver_abc
,
'Flat Recurisve extract top level file in deep nested archive(starts w/ dir)'
);
rmtree(
$tmpdir
);
$ver_abc
= catfile(
$tmpdir
,
'version.abc'
);
$b_tgz
= catfile(
$tmpdir
,
'b.tgz'
);
$c_bz2
= catfile(
$tmpdir
,
'c.bz2'
);
$d_zip
= catfile(
$tmpdir
,
'd.zip'
);
$e_7z
= catfile(
$tmpdir
,
'e.7z'
);
$dir_txt
= catfile(
$tmpdir
,
'dir.txt'
);
$base
= catfile(
$test_data_dir
,
$test_data_no
,
"a.rar"
);
$ret
=
$probe
->extract(
$base
,
$tmpdir
, 0, 1);
ok(
$ret
&&
-f
$dir_txt
&&
-f
$b_tgz
&&
!-f
$c_bz2
&&
!-f
$d_zip
&&
!-f
$e_7z
&&
!-f
$ver_abc
,
'Flat non-recurisve extract deep nested archive(starts w/ file)'
);
rmtree(
$tmpdir
);
$tmpdir
= tempdir(
'_arXXXXXXXX'
,
DIR
=> File::Spec->tmpdir());
$ver_abc
= catfile(
$tmpdir
,
'version.abc'
);
$b_tgz
= catfile(
$tmpdir
,
'b.tgz'
);
$c_bz2
= catfile(
$tmpdir
,
'c.bz2'
);
$d_zip
= catfile(
$tmpdir
,
'd.zip'
);
$e_7z
= catfile(
$tmpdir
,
'e.7z'
);
$dir_txt
= catfile(
$tmpdir
,
'dir.txt'
);
$ret
=
$probe
->extract(
$base
,
$tmpdir
, 1, 1);
ok(
$ret
&&
-f
$dir_txt
&&
-f
$b_tgz
&&
-f
$c_bz2
&&
-f
$d_zip
&&
-f
$e_7z
&&
-f
$ver_abc
,
'Flat Recurisve extract top level file in deep nested archive(starts w/ file)'
);
rmtree(
$tmpdir
);
}