line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# vim: set ts=2 sts=2 sw=2 expandtab smarttab: |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This file is part of Dist-Metadata |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# This software is copyright (c) 2011 by Randy Stauner. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
8
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
9
|
|
|
|
|
|
|
# |
10
|
4
|
|
|
4
|
|
476
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
182
|
|
11
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
255
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Dist::Metadata::Zip; |
14
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:RWSTAUNER'; |
15
|
|
|
|
|
|
|
# ABSTRACT: Enable Dist::Metadata for zip files |
16
|
|
|
|
|
|
|
$Dist::Metadata::Zip::VERSION = '0.926'; |
17
|
4
|
|
|
4
|
|
2603
|
use Archive::Zip 1.30 (); |
|
4
|
|
|
|
|
175054
|
|
|
4
|
|
|
|
|
116
|
|
18
|
4
|
|
|
4
|
|
33
|
use Carp (); # core |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
72
|
|
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
4
|
|
18
|
use parent 'Dist::Metadata::Archive'; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
32
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
push(@Dist::Metadata::CARP_NOT, __PACKAGE__); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub file_content { |
25
|
22
|
|
|
22
|
1
|
43
|
my ($self, $file) = @_; |
26
|
22
|
|
|
|
|
149
|
my ($content, $status) = $self->archive->contents( $self->full_path($file) ); |
27
|
22
|
50
|
|
|
|
16186
|
Carp::croak "Failed to get content of '$file' from archive" |
28
|
|
|
|
|
|
|
if $status != Archive::Zip::AZ_OK(); |
29
|
22
|
|
|
|
|
177
|
return $content; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub find_files { |
33
|
11
|
|
|
11
|
1
|
15
|
my ($self) = @_; |
34
|
|
|
|
|
|
|
return |
35
|
37
|
|
|
|
|
260
|
map { $_->fileName } |
|
37
|
|
|
|
|
375
|
|
36
|
11
|
|
|
|
|
65
|
grep { !$_->isDirectory } |
37
|
|
|
|
|
|
|
$self->archive->members; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub read_archive { |
41
|
11
|
|
|
11
|
1
|
198
|
my ($self, $file) = @_; |
42
|
|
|
|
|
|
|
|
43
|
11
|
|
|
|
|
67
|
my $archive = Archive::Zip->new(); |
44
|
11
|
50
|
|
|
|
331
|
$archive->read($file) == Archive::Zip::AZ_OK() |
45
|
|
|
|
|
|
|
or Carp::croak "Failed to read zip file!"; |
46
|
|
|
|
|
|
|
|
47
|
11
|
|
|
|
|
11337
|
return $archive; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |