line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LEOCHARRE::Digest; |
2
|
1
|
|
|
1
|
|
47247
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
3
|
1
|
|
|
1
|
|
4
|
use vars qw($VERSION @EXPORT_OK %EXPORT_TAGS @ISA); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
64
|
|
4
|
1
|
|
|
1
|
|
4
|
use Exporter; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
29
|
|
5
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
68
|
|
6
|
1
|
|
|
1
|
|
915
|
use String::ShellQuote; |
|
1
|
|
|
|
|
3113
|
|
|
1
|
|
|
|
|
637
|
|
7
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%02d", q$Revision: 1.1.1.1 $ =~ /(\d+)/g; |
8
|
|
|
|
|
|
|
@ISA = qw/Exporter/; |
9
|
|
|
|
|
|
|
@EXPORT_OK = qw(md5_cli); |
10
|
|
|
|
|
|
|
%EXPORT_TAGS = ( all => \@EXPORT_OK ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub md5_cli { |
13
|
2
|
|
|
2
|
1
|
8780
|
my $abs = String::ShellQuote::shell_quote($_[0]); |
14
|
|
|
|
|
|
|
#my $r = `md5sum $abs 2>&1`; # to hide stderr |
15
|
2
|
|
|
|
|
16679
|
my $r = `md5sum $abs`; |
16
|
2
|
100
|
|
|
|
115
|
$? and return; #and warn("Error getting md5sum on '$abs': err '$?'\n") and return; |
17
|
|
|
|
|
|
|
# md5sum already tells what the error is, if file is missing tells stderr what it was (the arg) |
18
|
1
|
|
|
|
|
16
|
chomp $r; |
19
|
1
|
|
|
|
|
35
|
$r=~s/\s.*//; |
20
|
1
|
|
|
|
|
7
|
$r=~s/^\W//; |
21
|
1
|
50
|
0
|
|
|
21
|
$r=~/^([0-9A-F]{32})/i or warn("Cant match 32 char sum into '$abs', result was '$r'") and return; |
22
|
1
|
|
|
|
|
51
|
return $1; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# # recreation of Digest::MD5::File |
26
|
|
|
|
|
|
|
# sub _md5_Digest_MD5 { |
27
|
|
|
|
|
|
|
# my $abs = shift; |
28
|
|
|
|
|
|
|
# # slurp into mem? |
29
|
|
|
|
|
|
|
# # this will eat the memory in the system |
30
|
|
|
|
|
|
|
# # |
31
|
|
|
|
|
|
|
# my $data = undef; |
32
|
|
|
|
|
|
|
# local $/; |
33
|
|
|
|
|
|
|
# open(FILE,'<',$abs); |
34
|
|
|
|
|
|
|
# $data = ; |
35
|
|
|
|
|
|
|
# require Digest::MD5; |
36
|
|
|
|
|
|
|
# my $md5 = Digest::MD5::md5_hex($data); |
37
|
|
|
|
|
|
|
# $data=undef; |
38
|
|
|
|
|
|
|
# return $md5; |
39
|
|
|
|
|
|
|
# } |
40
|
|
|
|
|
|
|
# |
41
|
|
|
|
|
|
|
# sub _md5_Digest_MD5_File { |
42
|
|
|
|
|
|
|
# my $abs = shift; |
43
|
|
|
|
|
|
|
# require Digest::MD5::File; |
44
|
|
|
|
|
|
|
# my $md5 = Digest::MD5::File::file_md5_hex($abs); |
45
|
|
|
|
|
|
|
# return $md5; |
46
|
|
|
|
|
|
|
# } |
47
|
|
|
|
|
|
|
# |
48
|
|
|
|
|
|
|
# # only read part of file -sketchy |
49
|
|
|
|
|
|
|
# sub _md5_lazy { |
50
|
|
|
|
|
|
|
# my $abs = shift; |
51
|
|
|
|
|
|
|
# |
52
|
|
|
|
|
|
|
# # set a length to read each time, a buffer |
53
|
|
|
|
|
|
|
# # let's set it at.. hmm... 25k |
54
|
|
|
|
|
|
|
# my $length = ( 1024 * 25 ); |
55
|
|
|
|
|
|
|
# my $chunk; |
56
|
|
|
|
|
|
|
# open( FILE, '<', $abs) or die("cant open for reading $abs, $!"); |
57
|
|
|
|
|
|
|
# read(FILE, $chunk, $length ); |
58
|
|
|
|
|
|
|
# close FILE; |
59
|
|
|
|
|
|
|
# return md5_hex($chunk); |
60
|
|
|
|
|
|
|
# } |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |