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