line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::QuickDB::Util; |
2
|
10
|
|
|
10
|
|
82
|
use strict; |
|
10
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
345
|
|
3
|
10
|
|
|
10
|
|
58
|
use warnings; |
|
10
|
|
|
|
|
32
|
|
|
10
|
|
|
|
|
485
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000021'; |
6
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
60
|
use IPC::Cmd qw/can_run/; |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
524
|
|
8
|
10
|
|
|
10
|
|
75
|
use Carp qw/confess/; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
568
|
|
9
|
|
|
|
|
|
|
|
10
|
10
|
|
|
10
|
|
70
|
use Importer Importer => 'import'; |
|
10
|
|
|
|
|
31
|
|
|
10
|
|
|
|
|
109
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw/clone_dir strip_hash_defaults/; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my ($RSYNC, $CP); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
BEGIN { |
17
|
10
|
|
|
10
|
|
1031
|
local $@; |
18
|
10
|
|
|
|
|
43
|
$RSYNC = can_run('rsync'); |
19
|
10
|
|
|
|
|
1009153
|
$CP = can_run('cp'); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub clone_dir { |
23
|
0
|
0
|
|
0
|
0
|
|
return _clone_dir_rsync(@_) if $RSYNC; |
24
|
0
|
0
|
|
|
|
|
return _clone_dir_cp(@_) if $CP; |
25
|
0
|
|
|
|
|
|
return _clone_dir_fcr(@_); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _clone_dir_rsync { |
29
|
0
|
|
|
0
|
|
|
my ($src, $dest, %params) = @_; |
30
|
0
|
0
|
|
|
|
|
system($RSYNC, '-a', '--exclude' => '.nfs*', $params{verbose} ? ( '-vP' ) : (), "$src/", $dest) and die "$RSYNC returned $?"; |
|
|
0
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _clone_dir_cp { |
34
|
0
|
|
|
0
|
|
|
my ($src, $dest, %params) = @_; |
35
|
0
|
0
|
|
|
|
|
system($CP, '-a', $params{verbose} ? ( '-v' ) : (), "$src/", $dest) and die "$CP returned $?"; |
|
|
0
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _clone_dir_fcr { |
39
|
0
|
|
|
0
|
|
|
my ($src, $dest, %params) = @_; |
40
|
0
|
|
|
|
|
|
require File::Copy::Recursive; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
File::Copy::Recursive::dircopy($src, $dest) or die "$!"; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub strip_hash_defaults { |
46
|
0
|
|
|
0
|
0
|
|
my ($hash, $defaults) = @_; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $out = {%$hash}; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
for my $key (keys %$defaults) { |
51
|
0
|
|
|
|
|
|
my $refout = ref($out->{$key}); |
52
|
0
|
|
|
|
|
|
my $refdef = ref($defaults->{$key}); |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
0
|
|
|
|
if ($refout eq $refdef && $refdef eq 'HASH') { |
55
|
0
|
|
|
|
|
|
$out->{$key} = strip_hash_defaults($out->{$key}, $defaults->{$key}); |
56
|
0
|
|
|
|
|
|
next; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
if ($refout ne $refdef) { |
60
|
0
|
|
|
|
|
|
delete $out->{$key}; |
61
|
0
|
|
|
|
|
|
next; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
10
|
|
|
10
|
|
7511
|
no warnings 'numeric'; |
|
10
|
|
|
|
|
32
|
|
|
10
|
|
|
|
|
1367
|
|
65
|
0
|
0
|
0
|
|
|
|
delete $out->{$key} if $out->{$key} && $out->{$key} eq $defaults->{$key}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return $out; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |