line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Csistck::Test::File; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
302
|
use 5.010; |
|
17
|
|
|
|
|
42
|
|
4
|
17
|
|
|
17
|
|
74
|
use strict; |
|
17
|
|
|
|
|
20
|
|
|
17
|
|
|
|
|
359
|
|
5
|
17
|
|
|
17
|
|
66
|
use warnings; |
|
17
|
|
|
|
|
19
|
|
|
17
|
|
|
|
|
487
|
|
6
|
|
|
|
|
|
|
|
7
|
17
|
|
|
17
|
|
70
|
use base 'Csistck::Test::FileBase'; |
|
17
|
|
|
|
|
21
|
|
|
17
|
|
|
|
|
7088
|
|
8
|
17
|
|
|
17
|
|
180
|
use Csistck::Oper qw/debug/; |
|
17
|
|
|
|
|
30
|
|
|
17
|
|
|
|
|
926
|
|
9
|
17
|
|
|
17
|
|
90
|
use Csistck::Util qw/hash_file hash_string/; |
|
17
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
1062
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw/file/; |
12
|
|
|
|
|
|
|
|
13
|
17
|
|
|
17
|
|
91
|
use Digest::MD5; |
|
17
|
|
|
|
|
27
|
|
|
17
|
|
|
|
|
565
|
|
14
|
17
|
|
|
17
|
|
81
|
use File::Basename; |
|
17
|
|
|
|
|
34
|
|
|
17
|
|
|
|
|
1062
|
|
15
|
17
|
|
|
17
|
|
85
|
use File::Copy; |
|
17
|
|
|
|
|
24
|
|
|
17
|
|
|
|
|
770
|
|
16
|
17
|
|
|
17
|
|
77
|
use FindBin; |
|
17
|
|
|
|
|
38
|
|
|
17
|
|
|
|
|
536
|
|
17
|
17
|
|
|
17
|
|
74
|
use File::stat; |
|
17
|
|
|
|
|
32
|
|
|
17
|
|
|
|
|
210
|
|
18
|
17
|
|
|
17
|
|
11998
|
use Template; |
|
17
|
|
|
|
|
317057
|
|
|
17
|
|
|
|
|
653
|
|
19
|
17
|
|
|
17
|
|
157
|
use Sys::Hostname::Long qw//; |
|
17
|
|
|
|
|
29
|
|
|
17
|
|
|
|
|
256
|
|
20
|
17
|
|
|
17
|
|
9566
|
use Text::Diff (); |
|
17
|
|
|
|
|
130767
|
|
|
17
|
|
|
|
|
4764
|
|
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
0
|
1438
|
sub file { Csistck::Test::File->new(@_); }; |
23
|
|
|
|
|
|
|
|
24
|
14
|
|
|
14
|
0
|
40
|
sub desc { sprintf("File check on %s", shift->dest); } |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub file_check { |
27
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
28
|
0
|
|
|
|
|
0
|
my ($dest, $src) = ($self->dest, $self->src); |
29
|
0
|
|
|
|
|
0
|
file_compare($src, $dest); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub file_repair { |
33
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
34
|
0
|
|
|
|
|
0
|
my ($dest, $src) = ($self->dest, $self->src); |
35
|
0
|
|
|
|
|
0
|
debug("Copying file: "); |
36
|
0
|
|
|
|
|
0
|
copy($src, $dest); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub file_diff { |
40
|
1
|
|
|
1
|
0
|
892
|
my $self = shift; |
41
|
1
|
|
|
|
|
19
|
my ($dest, $src) = ($self->dest, $self->src); |
42
|
0
|
|
|
|
|
|
say(Text::Diff::diff($dest, $src)); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Compare hashes between two files |
46
|
|
|
|
|
|
|
sub file_compare { |
47
|
0
|
|
|
0
|
0
|
|
my @files = @_; |
48
|
0
|
0
|
|
|
|
|
return 0 unless (scalar @files == 2); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Get hashes and return compare |
51
|
0
|
|
|
|
|
|
my ($hasha, $hashb) = map hash_file($_), @files; |
52
|
0
|
|
|
|
|
|
debug(sprintf "File compare result: ", $hasha, $hashb); |
53
|
0
|
|
|
|
|
|
return ($hasha eq $hashb); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
__END__ |