line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::StringToZip; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
83936
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
148
|
|
4
|
3
|
|
|
3
|
|
16
|
use vars qw(@ISA @EXPORT_OK $VERSION); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
389
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
17
|
use Carp qw(croak); |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
564
|
|
7
|
3
|
|
|
3
|
|
7474
|
use IO::String (); |
|
3
|
|
|
|
|
30687
|
|
|
3
|
|
|
|
|
82
|
|
8
|
3
|
|
|
3
|
|
4034
|
use Archive::Zip qw(:ERROR_CODES :CONSTANTS); |
|
3
|
|
|
|
|
338312
|
|
|
3
|
|
|
|
|
498
|
|
9
|
3
|
|
|
3
|
|
31
|
use base qw(Archive::Zip); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
976
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require Exporter; |
12
|
|
|
|
|
|
|
@ISA = qw(Exporter Archive::Zip::Archive Archive::Zip); |
13
|
|
|
|
|
|
|
@EXPORT_OK = qw(zipString); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$VERSION = '1.03'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub zipString { |
19
|
8
|
100
|
|
8
|
1
|
9752
|
my $self = ref($_[0]) ? shift : __PACKAGE__->new(); |
20
|
8
|
|
|
|
|
50
|
my ($string, $filename) = @_; |
21
|
|
|
|
|
|
|
|
22
|
8
|
100
|
|
|
|
67
|
croak 'Cannot archive an undefined string' unless defined $string; |
23
|
5
|
100
|
|
|
|
15
|
$filename = 'file.txt' unless $filename; |
24
|
|
|
|
|
|
|
|
25
|
5
|
|
|
|
|
33
|
my $SH = IO::String->new(); |
26
|
|
|
|
|
|
|
|
27
|
5
|
|
|
|
|
245
|
my $member = $self->addString($string, $filename); |
28
|
5
|
|
|
|
|
1239
|
$member->desiredCompressionMethod(COMPRESSION_DEFLATED); |
29
|
5
|
|
|
|
|
60
|
$member->desiredCompressionLevel( 9 ); |
30
|
|
|
|
|
|
|
|
31
|
5
|
|
|
|
|
63
|
my $status = $self->writeToFileHandle($SH); |
32
|
5
|
50
|
|
|
|
8831
|
die $! if $status != AZ_OK; |
33
|
|
|
|
|
|
|
|
34
|
5
|
|
|
|
|
18
|
binmode STDOUT; # necessary for Win32 and does no harm on *nix |
35
|
5
|
|
|
|
|
18
|
$SH->setpos(0); |
36
|
5
|
|
|
|
|
51
|
return do { local $/ = undef; $SH->getline }; |
|
5
|
|
|
|
|
21
|
|
|
5
|
|
|
|
|
18
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |