line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Find::Rule::DIZ; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
File::Find::Rule::DIZ - Rule to match the contents of a FILE_ID.DIZ |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use File::Find::Rule::DIZ; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my @files = find( diz => { text => qr/stuff and things/ }, in => '/archives' ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This module will search through a ZIP archive, specifically the contents of the FILE_ID.DIZ |
16
|
|
|
|
|
|
|
file in the archive. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
2
|
|
112776
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
118
|
|
21
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
67
|
|
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
2
|
|
2195
|
use File::Find::Rule; |
|
2
|
|
|
|
|
28631
|
|
|
2
|
|
|
|
|
21
|
|
24
|
2
|
|
|
2
|
|
126
|
use base qw( File::Find::Rule ); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
288
|
|
25
|
2
|
|
|
2
|
|
12
|
use vars qw( @EXPORT $VERSION ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
151
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
@EXPORT = @File::Find::Rule::EXPORT; |
28
|
|
|
|
|
|
|
$VERSION = '0.06'; |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
2
|
|
3277
|
use Archive::Zip; |
|
2
|
|
|
|
|
476215
|
|
|
2
|
|
|
|
|
1448
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 diz( %options ) |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my @files = find( diz => { text => qr/stuff and things/ }, in => '/archives' ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
For now, all you can do is search the text using a regex. Yehaw. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub File::Find::Rule::diz { |
43
|
2
|
|
|
2
|
0
|
3205
|
my $self = shift->_force_object; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Procedural interface allows passing arguments as a hashref. |
46
|
2
|
50
|
|
|
|
22
|
my %criteria = UNIVERSAL::isa( $_[ 0 ], 'HASH' ) ? %{ $_[ 0 ] } : @_; |
|
2
|
|
|
|
|
10
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$self->exec( sub { |
49
|
6
|
|
|
6
|
|
2773
|
my $file = shift; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# is it a binary file? |
52
|
6
|
100
|
|
|
|
2110
|
return unless -B $file; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# is it a zip file? |
55
|
4
|
|
|
|
|
48
|
my $zip = Archive::Zip->new( $file ); |
56
|
4
|
100
|
|
|
|
14928
|
return unless $zip; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# does it contain a file_id.diz? |
59
|
2
|
|
|
|
|
15
|
my $member = $zip->memberNamed( 'FILE_ID.DIZ' ); |
60
|
2
|
50
|
|
|
|
47
|
return unless $member; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# does it match the desired data? |
63
|
2
|
|
|
|
|
16
|
my $diz = $member->contents; |
64
|
2
|
100
|
|
|
|
7796
|
return unless $diz =~ $criteria{ text }; |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
52
|
return 1; |
67
|
2
|
|
|
|
|
27
|
} ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 AUTHOR |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=over 4 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item * Brian Cassidy Ebricas@cpan.orgE |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=back |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Copyright 2007 by Brian Cassidy |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
83
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SEE ALSO |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=over 4 |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item * File::Find::Rule |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item * File::Find::Rule::MP3Info |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=back |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |