line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Find::Rule::BOM; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
111008
|
use base qw(File::Find::Rule); |
|
6
|
|
|
|
|
43
|
|
|
6
|
|
|
|
|
1679
|
|
4
|
6
|
|
|
6
|
|
17032
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
115
|
|
5
|
6
|
|
|
6
|
|
27
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
175
|
|
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
6561
|
use String::BOM qw(file_has_bom); |
|
6
|
|
|
|
|
123
|
|
|
6
|
|
|
|
|
29
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.02; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Detect BOM. |
12
|
|
|
|
|
|
|
sub File::Find::Rule::bom { |
13
|
1
|
|
|
1
|
0
|
233
|
my $file_find_rule = shift; |
14
|
1
|
|
|
|
|
2
|
return _bom($file_find_rule); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Detect UTF-8 BOM. |
18
|
|
|
|
|
|
|
sub File::Find::Rule::bom_utf8 { |
19
|
1
|
|
|
1
|
0
|
231
|
my $file_find_rule = shift; |
20
|
1
|
|
|
|
|
3
|
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
|
216
|
my $file_find_rule = shift; |
26
|
1
|
|
|
|
|
3
|
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
|
218
|
my $file_find_rule = shift; |
32
|
1
|
|
|
|
|
3
|
return _bom($file_find_rule, 'UTF-32'); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _bom { |
36
|
4
|
|
|
4
|
|
12
|
my ($file_find_rule, $concrete_bom) = @_; |
37
|
4
|
|
|
|
|
15
|
my $self = $file_find_rule->_force_object; |
38
|
|
|
|
|
|
|
return $self->file->exec(sub{ |
39
|
16
|
|
|
16
|
|
3899
|
my $file = shift; |
40
|
16
|
|
|
|
|
57
|
my $bom = file_has_bom($file); |
41
|
16
|
100
|
|
|
|
1315
|
return 0 unless $bom; |
42
|
12
|
100
|
|
|
|
38
|
if ($concrete_bom) { |
43
|
9
|
100
|
|
|
|
205
|
return $concrete_bom eq $bom ? 1 : 0 |
44
|
|
|
|
|
|
|
} else { |
45
|
3
|
|
|
|
|
64
|
return 1; |
46
|
|
|
|
|
|
|
} |
47
|
4
|
|
|
|
|
156
|
}); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |