line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Find::Rule::BOM; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
117844
|
use base qw(File::Find::Rule); |
|
6
|
|
|
|
|
45
|
|
|
6
|
|
|
|
|
1925
|
|
4
|
6
|
|
|
6
|
|
17615
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
122
|
|
5
|
6
|
|
|
6
|
|
28
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
196
|
|
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
6930
|
use String::BOM qw(file_has_bom); |
|
6
|
|
|
|
|
125
|
|
|
6
|
|
|
|
|
30
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.03; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Detect BOM. |
12
|
|
|
|
|
|
|
sub File::Find::Rule::bom { |
13
|
1
|
|
|
1
|
0
|
240
|
my $file_find_rule = shift; |
14
|
1
|
|
|
|
|
4
|
return _bom($file_find_rule); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Detect UTF-8 BOM. |
18
|
|
|
|
|
|
|
sub File::Find::Rule::bom_utf8 { |
19
|
1
|
|
|
1
|
0
|
266
|
my $file_find_rule = shift; |
20
|
1
|
|
|
|
|
4
|
return _bom($file_find_rule, 'UTF-8'); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Detect UTF-16 BOM. |
24
|
|
|
|
|
|
|
sub File::Find::Rule::bom_utf16 { |
25
|
1
|
|
|
1
|
0
|
266
|
my $file_find_rule = shift; |
26
|
1
|
|
|
|
|
4
|
return _bom($file_find_rule, 'UTF-16'); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Detect UTF-32 BOM. |
30
|
|
|
|
|
|
|
sub File::Find::Rule::bom_utf32 { |
31
|
1
|
|
|
1
|
0
|
274
|
my $file_find_rule = shift; |
32
|
1
|
|
|
|
|
4
|
return _bom($file_find_rule, 'UTF-32'); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _bom { |
36
|
4
|
|
|
4
|
|
14
|
my ($file_find_rule, $concrete_bom) = @_; |
37
|
4
|
|
|
|
|
20
|
my $self = $file_find_rule->_force_object; |
38
|
|
|
|
|
|
|
return $self->file->exec(sub{ |
39
|
16
|
|
|
16
|
|
4347
|
my $file = shift; |
40
|
16
|
|
|
|
|
74
|
my $bom = file_has_bom($file); |
41
|
16
|
100
|
|
|
|
1473
|
return 0 unless $bom; |
42
|
12
|
100
|
|
|
|
80
|
if ($concrete_bom) { |
43
|
9
|
100
|
|
|
|
224
|
return $concrete_bom eq $bom ? 1 : 0 |
44
|
|
|
|
|
|
|
} else { |
45
|
3
|
|
|
|
|
65
|
return 1; |
46
|
|
|
|
|
|
|
} |
47
|
4
|
|
|
|
|
178
|
}); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |