line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OPM::Maker::Utils; |
2
|
|
|
|
|
|
|
$OPM::Maker::Utils::VERSION = '1.17'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Utility functions for OPM::Maker |
4
|
|
|
|
|
|
|
|
5
|
44
|
|
|
44
|
|
308
|
use strict; |
|
44
|
|
|
|
|
225
|
|
|
44
|
|
|
|
|
1358
|
|
6
|
44
|
|
|
44
|
|
223
|
use warnings; |
|
44
|
|
|
|
|
79
|
|
|
44
|
|
|
|
|
1238
|
|
7
|
|
|
|
|
|
|
|
8
|
44
|
|
|
44
|
|
279
|
use Exporter 'import'; |
|
44
|
|
|
|
|
85
|
|
|
44
|
|
|
|
|
1172
|
|
9
|
|
|
|
|
|
|
|
10
|
44
|
|
|
44
|
|
12625
|
use File::Find::Rule; |
|
44
|
|
|
|
|
202610
|
|
|
44
|
|
|
|
|
412
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
13
|
|
|
|
|
|
|
reformat_size |
14
|
|
|
|
|
|
|
check_args_sopm |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub reformat_size { |
18
|
32
|
|
|
32
|
1
|
77
|
my ($size) = @_; |
19
|
|
|
|
|
|
|
|
20
|
32
|
|
|
|
|
162
|
$size =~ m{\A(?[0-9]+)(?[MmGgKk])?\z}; |
21
|
|
|
|
|
|
|
|
22
|
32
|
50
|
|
13
|
|
271
|
return 0 if !$+{count}; |
|
13
|
|
|
|
|
7602
|
|
|
13
|
|
|
|
|
4988
|
|
|
13
|
|
|
|
|
3590
|
|
23
|
|
|
|
|
|
|
|
24
|
32
|
|
100
|
|
|
1131
|
my $unit = lc( $+{unit} // 'b' ); |
25
|
|
|
|
|
|
|
|
26
|
32
|
100
|
|
|
|
109
|
my $factor = |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$unit eq 'k' ? 1024 : |
28
|
|
|
|
|
|
|
$unit eq 'm' ? 1024 * 1024 : |
29
|
|
|
|
|
|
|
$unit eq 'g' ? 1024 * 1024 * 1024: |
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
; |
32
|
|
|
|
|
|
|
|
33
|
32
|
|
|
|
|
148
|
return $+{count} * $factor; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub check_args_sopm { |
37
|
119
|
|
|
119
|
1
|
271
|
my ($args, $opm) = @_; |
38
|
|
|
|
|
|
|
|
39
|
119
|
100
|
100
|
|
|
693
|
return if $args and 'ARRAY' ne ref $args; |
40
|
|
|
|
|
|
|
|
41
|
110
|
|
|
|
|
205
|
my $sopm = $args->[0]; |
42
|
|
|
|
|
|
|
|
43
|
110
|
100
|
|
|
|
321
|
my @suffixes = $opm ? ('*.opm', '*.sopm') : ('*.sopm'); |
44
|
|
|
|
|
|
|
|
45
|
110
|
100
|
|
|
|
240
|
if ( !$sopm ) { |
46
|
|
|
|
|
|
|
my @all_sopm = map { |
47
|
43
|
|
|
|
|
1173
|
$_ =~ s{\A\.[/\\]}{}; |
|
24
|
|
|
|
|
19980
|
|
48
|
24
|
|
|
|
|
71
|
$_; |
49
|
|
|
|
|
|
|
} File::Find::Rule->file->name(@suffixes)->maxdepth(1)->in('.'); |
50
|
|
|
|
|
|
|
|
51
|
43
|
100
|
|
|
|
34735
|
die 'Found more than one .sopm file' if @all_sopm > 1; |
52
|
|
|
|
|
|
|
|
53
|
42
|
|
|
|
|
112
|
$sopm = $all_sopm[0]; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
109
|
|
100
|
|
|
302
|
$sopm //= ''; |
57
|
|
|
|
|
|
|
|
58
|
109
|
100
|
|
|
|
226
|
my $re = $opm ? 's?opm' : 'sopm'; |
59
|
109
|
100
|
100
|
|
|
2555
|
return if $sopm !~ m{\.$re\z} or !-f $sopm; |
60
|
|
|
|
|
|
|
|
61
|
68
|
|
|
|
|
394
|
return $sopm; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |