line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Tools::GenTemp; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.000156'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
922
|
use File::Temp qw/tempdir/; |
|
1
|
|
|
|
|
19933
|
|
|
1
|
|
|
|
|
63
|
|
9
|
1
|
|
|
1
|
|
7
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT = qw{gen_temp}; |
12
|
1
|
|
|
1
|
|
5
|
use base 'Exporter'; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
318
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub gen_temp { |
15
|
1
|
|
|
1
|
1
|
29
|
my %args = @_; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
50
|
|
|
23
|
my $tempdir_args = delete $args{'-tempdir'} || [CLEANUP => 1, TMPDIR => 1]; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
10
|
my $tmp = tempdir(@$tempdir_args); |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
810
|
gen_dir($tmp, \%args); |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
15
|
return $tmp; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub gen_dir { |
27
|
3
|
|
|
3
|
0
|
9
|
my ($dir, $content) = @_; |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
15
|
for my $path (keys %$content) { |
30
|
6
|
|
|
|
|
77
|
my $fq = File::Spec->catfile($dir, $path); |
31
|
6
|
|
|
|
|
22
|
my $inside = $content->{$path}; |
32
|
|
|
|
|
|
|
|
33
|
6
|
100
|
|
|
|
16
|
if (ref $inside) { |
34
|
|
|
|
|
|
|
# Subdirectory |
35
|
2
|
50
|
|
|
|
128
|
mkdir($fq) or die "Could not make dir '$fq': $!"; |
36
|
2
|
|
|
|
|
18
|
gen_dir($fq, $inside); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
4
|
50
|
|
|
|
341
|
open(my $fh, '>', $fq) or die "Could not open file '$fq' for writing: $!"; |
40
|
4
|
|
|
|
|
48
|
print $fh $inside; |
41
|
4
|
|
|
|
|
669
|
close($fh); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |