|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Csistck::Test::File;  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
 
 | 
338
 | 
 use 5.010;  | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
61
 | 
    | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
912
 | 
    | 
| 
4
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
 
 | 
85
 | 
 use strict;  | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
30
 | 
    | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
612
 | 
    | 
| 
5
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
 
 | 
95
 | 
 use warnings;  | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
32
 | 
    | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
530
 | 
    | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
7
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
 
 | 
124
 | 
 use base 'Csistck::Test::FileBase';  | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
30
 | 
    | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11770
 | 
    | 
| 
8
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
 
 | 
269
 | 
 use Csistck::Oper qw/debug/;  | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
40
 | 
    | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
946
 | 
    | 
| 
9
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
 
 | 
96
 | 
 use Csistck::Util qw/hash_file hash_string/;  | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
38
 | 
    | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1636
 | 
    | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our @EXPORT_OK = qw/file/;  | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
13
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
 
 | 
108
 | 
 use Digest::MD5;  | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
36
 | 
    | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
557
 | 
    | 
| 
14
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
 
 | 
105
 | 
 use File::Basename;  | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
83
 | 
    | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1100
 | 
    | 
| 
15
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
 
 | 
150
 | 
 use File::Copy;  | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
36
 | 
    | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1694
 | 
    | 
| 
16
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
 
 | 
99
 | 
 use FindBin;  | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
41
 | 
    | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
769
 | 
    | 
| 
17
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
 
 | 
96
 | 
 use File::stat;  | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
36
 | 
    | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1263
 | 
    | 
| 
18
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
 
 | 
65525
 | 
 use Template;  | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5165258
 | 
    | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
550
 | 
    | 
| 
19
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
 
 | 
174
 | 
 use Sys::Hostname::Long qw//;  | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
38
 | 
    | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
254
 | 
    | 
| 
20
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
 
 | 
17508
 | 
 use Text::Diff ();  | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
219058
 | 
    | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5726
 | 
    | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
22
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
  
1
  
 | 
1597
 | 
 sub file { Csistck::Test::File->new(@_); };  | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
24
 | 
14
 | 
 
 | 
 
 | 
  
14
  
 | 
  
0
  
 | 
45
 | 
 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
  
 | 
1720
 | 
     my $self = shift;  | 
| 
41
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
24
 | 
     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__  |