| 1 | package Archive::Any::Create::Zip; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use Archive::Zip qw(:ERROR_CODES); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | sub init { | ||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 7 | 2 | my $self = shift; | |||||||||
| 8 | 2 | my($opt) = @_; | |||||||||
| 9 | 2 | $self->{zip} = Archive::Zip->new; | |||||||||
| 10 | } | ||||||||||
| 11 | |||||||||||
| 12 | 2 | ▶ | sub container { | ||||||||
|
Subroutine
container: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 13 | 2 | my $self = shift; | |||||||||
| 14 | 2 | my($dir) = @_; | |||||||||
| 15 | 2 | $self->{container} = $dir; | |||||||||
| 16 | 2 | $self->{zip}->addDirectory("$dir/"); | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 4 | ▶ | sub add_file { | ||||||||
|
Subroutine
add_file: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 20 | 4 | my $self = shift; | |||||||||
| 21 | 4 | my($file, $data) = @_; | |||||||||
| 22 | 4 | ▶ | $file = "$self->{container}/$file" if $self->{container}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 4 | $self->{zip}->addString($data, $file); | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 1 | ▶ | sub write_file { | ||||||||
|
Subroutine
write_file: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 27 | 1 | my $self = shift; | |||||||||
| 28 | 1 | my($file) = @_; | |||||||||
| 29 | 1 | my $err = $self->{zip}->writeToFileNamed($file); | |||||||||
| 30 | 1 | ▶ | $err == AZ_OK | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | or throw Archive::Any::Create::Error(error => "write_file failed ($err)"); | ||||||||||
| 32 | 1 | 1; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 1 | ▶ | sub write_filehandle { | ||||||||
|
Subroutine
write_filehandle: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 36 | 1 | my $self = shift; | |||||||||
| 37 | 1 | my($fh) = @_; | |||||||||
| 38 | 1 | my $err = $self->{zip}->writeToFileHandle($fh); | |||||||||
| 39 | 1 | ▶ | $err == AZ_OK | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | or throw Archive::Any::Create::Error(error => "write_filehandle failed ($err)"); | ||||||||||
| 41 | 1 | 1; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 1 | 1; | |||||||||