| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Archive::SevenZip::Entry; |
|
2
|
13
|
|
|
13
|
|
78
|
use strict; |
|
|
13
|
|
|
|
|
25
|
|
|
|
13
|
|
|
|
|
478
|
|
|
3
|
13
|
|
|
13
|
|
93
|
use warnings; |
|
|
13
|
|
|
|
|
22
|
|
|
|
13
|
|
|
|
|
604
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
13
|
|
|
13
|
|
7659
|
use Archive::Zip::Member; |
|
|
13
|
|
|
|
|
1086483
|
|
|
|
13
|
|
|
|
|
1074
|
|
|
6
|
13
|
|
|
13
|
|
7285
|
use Time::Piece; # for strptime |
|
|
13
|
|
|
|
|
131551
|
|
|
|
13
|
|
|
|
|
68
|
|
|
7
|
13
|
|
|
13
|
|
1205
|
use File::Basename (); |
|
|
13
|
|
|
|
|
48
|
|
|
|
13
|
|
|
|
|
223
|
|
|
8
|
13
|
|
|
13
|
|
7963
|
use Path::Class (); |
|
|
13
|
|
|
|
|
257411
|
|
|
|
13
|
|
|
|
|
7897
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION= '0.20'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Archive::SevenZip::Entry - a member of an archive |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use POSIX 'strftime'; |
|
19
|
|
|
|
|
|
|
for my $entry ( $ar->list ) { |
|
20
|
|
|
|
|
|
|
print $entry->fileName,"\n"; |
|
21
|
|
|
|
|
|
|
print strftime('%Y-%m-%d %H:%M', gmtime($entry->lastModTime)),"\n"; |
|
22
|
|
|
|
|
|
|
my $content = $entry->slurp(); |
|
23
|
|
|
|
|
|
|
print $content; |
|
24
|
|
|
|
|
|
|
}; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
|
29
|
0
|
|
|
0
|
0
|
|
my( $class, %options) = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
bless \%options => $class |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 METHODS |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=over 4 |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item C<< ->archive >> |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $ar = $entry->archive(); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Returns the containing archive as an L object. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub archive { |
|
47
|
|
|
|
|
|
|
$_[0]->{_Container} |
|
48
|
0
|
|
|
0
|
1
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item C<< ->fileName >> |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $fn = $entry->fileName(); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Returns the stored path |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub fileName { |
|
59
|
0
|
|
|
0
|
1
|
|
my( $self ) = @_; |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my $res = $self->{Path}; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Normalize to unixy path names |
|
64
|
0
|
|
|
|
|
|
$res =~ s!\\!/!g; |
|
65
|
|
|
|
|
|
|
# If we're a directory, append the slash: |
|
66
|
0
|
0
|
0
|
|
|
|
if( exists $self->{Folder} and $self->{Folder} eq '+') { |
|
67
|
0
|
|
|
|
|
|
$res .= '/'; |
|
68
|
|
|
|
|
|
|
}; |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$res |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item C<< ->basename >> |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $fn = $entry->basename(); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Returns the stored filename without a directory |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# Class::Path API |
|
82
|
|
|
|
|
|
|
sub basename { |
|
83
|
0
|
|
|
0
|
1
|
|
Path::Class::file( $_[0]->{Path} )->basename |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item C<< ->components >> |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my @parts = $entry->components(); |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Returns the stored filename as an array of directory names and the file name |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub components { |
|
95
|
0
|
|
|
0
|
1
|
|
my $cp = file( $_[0]->{Path} ); |
|
96
|
0
|
|
|
|
|
|
$cp->components() |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item C<< ->lastModTime >> |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $epoch = $entry->lastModTime(); |
|
102
|
|
|
|
|
|
|
print strftime('%Y-%m-%d %H:%M', $epoch),"\n"; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Returns the time of last modification of the stored file as number of seconds |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub lastModTime { |
|
109
|
0
|
|
|
0
|
1
|
|
(my $dt = $_[0]->{Modified}) =~ s/\.\d+$//; |
|
110
|
0
|
|
|
|
|
|
Time::Piece->strptime($dt, '%Y-%m-%d %H:%M:%S')->epoch; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub lastModFileDateTime { |
|
114
|
0
|
|
|
0
|
0
|
|
Archive::Zip::Member::_unixToDosTime($_[0]->lastModTime()) |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub crc32 { |
|
118
|
0
|
|
|
0
|
0
|
|
hex( $_[0]->{CRC} ); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub crc32String { |
|
122
|
0
|
|
|
0
|
0
|
|
lc $_[0]->{CRC}; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub desiredCompressionMethod { |
|
126
|
|
|
|
|
|
|
$_[0]->{Method} |
|
127
|
0
|
|
|
0
|
0
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item C<< ->uncompressedSize >> |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my $size = $entry->uncompressedSize(); |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Returns the uncompressed size of the stored file in bytes |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub uncompressedSize { |
|
138
|
|
|
|
|
|
|
$_[0]->{Size} |
|
139
|
0
|
|
|
0
|
1
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub dir { |
|
142
|
|
|
|
|
|
|
# We need to return the appropriate class here |
|
143
|
|
|
|
|
|
|
# so that further calls to (like) dir->list |
|
144
|
|
|
|
|
|
|
# still work properly |
|
145
|
0
|
|
|
0
|
0
|
|
die "->dir Not implemented"; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item C<< ->open $binmode >> |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
my $fh = $entry->open(':raw'); |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Opens a filehandle for the uncompressed data |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub open { |
|
157
|
0
|
|
|
0
|
1
|
|
my( $self, $mode, $permissions )= @_; |
|
158
|
0
|
|
|
|
|
|
$self->archive->openMemberFH( membername => $self->fileName, binmode => $mode ); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item C<< ->fh $binmode >> |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
my $fh = $entry->fh(':raw'); |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Opens a filehandle for the uncompressed data |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
|
168
|
|
|
|
|
|
|
|
|
169
|
13
|
|
|
13
|
|
145
|
{ no warnings 'once'; |
|
|
13
|
|
|
|
|
24
|
|
|
|
13
|
|
|
|
|
2947
|
|
|
170
|
|
|
|
|
|
|
*fh = \&open; # Archive::Zip API |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item C<< ->slurp %options >> |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
my $content = $entry->slurp( iomode => ':raw'); |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Reads the content |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=cut |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
# Path::Class API |
|
182
|
|
|
|
|
|
|
sub slurp { |
|
183
|
0
|
|
|
0
|
1
|
|
my( $self, %options )= @_; |
|
184
|
0
|
|
|
|
|
|
my $fh = $self->archive->openMemberFH( membername => $self->fileName, binmode => $options{ iomode } ); |
|
185
|
0
|
|
|
|
|
|
local $/; |
|
186
|
|
|
|
|
|
|
<$fh> |
|
187
|
0
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
# Archive::Zip API |
|
190
|
|
|
|
|
|
|
#externalFileName() |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
# Archive::Zip API |
|
193
|
|
|
|
|
|
|
#fileName() |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
# Archive::Zip API |
|
196
|
|
|
|
|
|
|
#lastModFileDateTime() |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# Archive::Zip API |
|
199
|
|
|
|
|
|
|
#lastModTime() |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item C<< ->extractToFileNamed $name >> |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
$entry->extractToFileNamed( '/tmp/foo.txt' ); |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Extracts the data |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=back |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=cut |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
# Archive::Zip API |
|
212
|
|
|
|
|
|
|
sub extractToFileNamed { |
|
213
|
0
|
|
|
0
|
1
|
|
my($self, $target) = @_; |
|
214
|
0
|
|
|
|
|
|
$self->archive->extractMember( $self->fileName, $target ); |
|
215
|
|
|
|
|
|
|
}; |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
1; |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
The public repository of this module is |
|
222
|
|
|
|
|
|
|
L. |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 SUPPORT |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
The public support forum of this module is |
|
227
|
|
|
|
|
|
|
L. |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head1 BUG TRACKER |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Please report bugs in this module via the RT CPAN bug queue at |
|
232
|
|
|
|
|
|
|
L |
|
233
|
|
|
|
|
|
|
or via mail to L. |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head1 AUTHOR |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
Max Maischein C |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head1 COPYRIGHT (c) |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
Copyright 2015-2024 by Max Maischein C. |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 LICENSE |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
This module is released under the same terms as Perl itself. |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=cut |