File Coverage

blib/lib/Archive/SevenZip/Entry.pm
Criterion Covered Total %
statement 21 49 42.8
branch 0 2 0.0
condition 0 3 0.0
subroutine 7 22 31.8
pod 0 15 0.0
total 28 91 30.7


line stmt bran cond sub pod time code
1             package Archive::SevenZip::Entry;
2 13     13   90 use strict;
  13         23  
  13         376  
3 13     13   67 use warnings;
  13         25  
  13         315  
4              
5 13     13   7177 use Archive::Zip::Member;
  13         946769  
  13         859  
6 13     13   6652 use Time::Piece; # for strptime
  13         94562  
  13         85  
7 13     13   1026 use File::Basename ();
  13         33  
  13         215  
8 13     13   5874 use Path::Class ();
  13         238802  
  13         6488  
9              
10             our $VERSION= '0.19';
11              
12             sub new {
13 0     0 0   my( $class, %options) = @_;
14              
15 0           bless \%options => $class
16             }
17              
18             sub archive {
19             $_[0]->{_Container}
20 0     0 0   }
21              
22             sub fileName {
23 0     0 0   my( $self ) = @_;
24              
25 0           my $res = $self->{Path};
26              
27             # Normalize to unixy path names
28 0           $res =~ s!\\!/!g;
29             # If we're a directory, append the slash:
30 0 0 0       if( exists $self->{Folder} and $self->{Folder} eq '+') {
31 0           $res .= '/';
32             };
33              
34 0           $res
35             }
36              
37             # Class::Path API
38             sub basename {
39 0     0 0   Path::Class::file( $_[0]->{Path} )->basename
40             }
41              
42             sub components {
43 0     0 0   my $cp = file( $_[0]->{Path} );
44 0           $cp->components()
45             }
46              
47             sub lastModTime {
48 0     0 0   (my $dt = $_[0]->{Modified}) =~ s/\.\d+$//;
49 0           Time::Piece->strptime($dt, '%Y-%m-%d %H:%M:%S')->epoch;
50             }
51              
52             sub lastModFileDateTime {
53 0     0 0   Archive::Zip::Member::_unixToDosTime($_[0]->lastModTime())
54             }
55              
56             sub crc32 {
57 0     0 0   hex( $_[0]->{CRC} );
58             }
59              
60             sub crc32String {
61 0     0 0   lc $_[0]->{CRC};
62             }
63              
64             sub desiredCompressionMethod {
65             $_[0]->{Method}
66 0     0 0   }
67              
68             sub uncompressedSize {
69             $_[0]->{Size}
70 0     0 0   }
71              
72             sub dir {
73             # We need to return the appropriate class here
74             # so that further calls to (like) dir->list
75             # still work properly
76 0     0 0   die "->dir Not implemented";
77             }
78              
79             sub open {
80 0     0 0   my( $self, $mode, $permissions )= @_;
81 0           $self->archive->openMemberFH( membername => $self->fileName, binmode => $mode );
82             }
83 13     13   132 { no warnings 'once';
  13         49  
  13         2781  
84             *fh = \&open; # Archive::Zip API
85             }
86              
87             # Path::Class API
88             sub slurp {
89 0     0 0   my( $self, %options )= @_;
90 0           my $fh = $self->archive->openMemberFH( membername => $self->fileName, binmode => $options{ iomode } );
91 0           local $/;
92             <$fh>
93 0           }
94              
95             # Archive::Zip API
96             #externalFileName()
97              
98             # Archive::Zip API
99             #fileName()
100              
101             # Archive::Zip API
102             #lastModFileDateTime()
103              
104             # Archive::Zip API
105             #lastModTime()
106              
107             # Archive::Zip API
108             sub extractToFileNamed {
109 0     0 0   my($self, $target) = @_;
110 0           $self->archive->extractMember( $self->fileName, $target );
111             };
112              
113             1;
114              
115             =head1 REPOSITORY
116              
117             The public repository of this module is
118             L.
119              
120             =head1 SUPPORT
121              
122             The public support forum of this module is
123             L.
124              
125             =head1 BUG TRACKER
126              
127             Please report bugs in this module via the RT CPAN bug queue at
128             L
129             or via mail to L.
130              
131             =head1 AUTHOR
132              
133             Max Maischein C
134              
135             =head1 COPYRIGHT (c)
136              
137             Copyright 2015-2022 by Max Maischein C.
138              
139             =head1 LICENSE
140              
141             This module is released under the same terms as Perl itself.
142              
143             =cut