#!/usr/bin/perl -w
BEGIN {
if
(-d
't'
) {
push
@INC
,
't'
;
}
}
my
$test_data_dir
= get_test_data_dir();
my
$test_data_no
=
'tc4'
;
my
$map
= {};
my
$tmpdir
= tempdir(
'_arXXXXXXXX'
,
DIR
=> File::Spec->tmpdir());
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'
);
$probe
->working_dir(
$tmpdir
);
$probe
->add_pattern(
'abc.d$'
,
sub
{
my
(
$pattern
,
$file_ref
) =
@_
;
if
(
@$file_ref
) {
$map
->{dot_d} =
$probe
->strip_dir(
$tmpdir
,
$file_ref
->[0]);
}
else
{
$map
->{dot_d} =
''
;
}
});
$probe
->add_pattern(
'version\.abc'
,
sub
{
my
(
$pattern
,
$file_ref
) =
@_
;
if
(
@$file_ref
) {
$map
->{version} =
$probe
->strip_dir(
$tmpdir
,
$file_ref
->[0]);
}
else
{
$map
->{version} =
''
;
}
});
$probe
->add_pattern(
'\.hpp$'
,
sub
{
my
(
$pattern
,
$file_ref
) =
@_
;
if
(
@$file_ref
) {
$map
->{hpp} =
$probe
->strip_dir(
$tmpdir
,
$file_ref
->[0]);
}
else
{
$map
->{hpp} =
''
;
}
});
$probe
->add_pattern(
'\.go'
,
sub
{
my
(
$pattern
,
$file_ref
) =
@_
;
if
(
@$file_ref
) {
$map
->{go} =
$probe
->strip_dir(
$tmpdir
,
$file_ref
->[0]);
}
else
{
$map
->{go} =
''
;
}
});
my
$base_dir
= catdir(
$test_data_dir
,
$test_data_no
);
$probe
->reset_matches();
$probe
->search(
$base_dir
, 1);
my
$abc
= catfile(
$tmpdir
,
'a.rar__'
,
'abc\'s.zip'
);
ok(-f
$abc
,
'single quote in file name zip existence test'
);
my
$exp
= catfile(
'a.rar__'
,
'abc\'s.zip__'
,
'abc.d'
);
is(
$map
->{dot_d},
$exp
,
'single quote in zip file name test'
);
$exp
= catfile(
'a.zip__'
,
'\\version.abc'
);
is(
$map
->{version},
$exp
,
'bashslash in file name test'
);
$exp
= catfile(
'b.zip__'
,
'cpp'
,
'quick & dirty sort.hpp'
);
is(
$map
->{hpp},
$exp
,
'space in file name test'
);
$exp
= catfile(
'c.zip__'
,
"\\Rock & Roll 't.zip__"
,
'go'
,
'hello.go'
);
is(
$map
->{go},
$exp
,
'space, single quote, backslash in file name test'
);
}
rmtree(
$tmpdir
);