| Filename | /home/micha/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/Archive/Zip/NewFileMember.pm |
| Statements | Executed 9 statements in 287µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 11µs | 11µs | Archive::Zip::NewFileMember::BEGIN@6 |
| 1 | 1 | 1 | 10µs | 12µs | Archive::Zip::NewFileMember::BEGIN@3 |
| 1 | 1 | 1 | 4µs | 122µs | Archive::Zip::NewFileMember::BEGIN@11 |
| 1 | 1 | 1 | 4µs | 21µs | Archive::Zip::NewFileMember::BEGIN@4 |
| 0 | 0 | 0 | 0s | 0s | Archive::Zip::NewFileMember::_newFromFileNamed |
| 0 | 0 | 0 | 0s | 0s | Archive::Zip::NewFileMember::_readRawChunk |
| 0 | 0 | 0 | 0s | 0s | Archive::Zip::NewFileMember::extractToFileNamed |
| 0 | 0 | 0 | 0s | 0s | Archive::Zip::NewFileMember::rewindData |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Archive::Zip::NewFileMember; | ||||
| 2 | |||||
| 3 | 2 | 22µs | 2 | 13µs | # spent 12µs (10+2) within Archive::Zip::NewFileMember::BEGIN@3 which was called:
# once (10µs+2µs) by Spreadsheet::ParseXLSX::BEGIN@11 at line 3 # spent 12µs making 1 call to Archive::Zip::NewFileMember::BEGIN@3
# spent 2µs making 1 call to strict::import |
| 4 | 2 | 24µs | 2 | 39µs | # spent 21µs (4+18) within Archive::Zip::NewFileMember::BEGIN@4 which was called:
# once (4µs+18µs) by Spreadsheet::ParseXLSX::BEGIN@11 at line 4 # spent 21µs making 1 call to Archive::Zip::NewFileMember::BEGIN@4
# spent 18µs making 1 call to vars::import |
| 5 | |||||
| 6 | # spent 11µs within Archive::Zip::NewFileMember::BEGIN@6 which was called:
# once (11µs+0s) by Spreadsheet::ParseXLSX::BEGIN@11 at line 9 | ||||
| 7 | 1 | 200ns | $VERSION = '1.68'; | ||
| 8 | 1 | 11µs | @ISA = qw ( Archive::Zip::FileMember ); | ||
| 9 | 1 | 16µs | 1 | 11µs | } # spent 11µs making 1 call to Archive::Zip::NewFileMember::BEGIN@6 |
| 10 | |||||
| 11 | 1 | 2µs | 1 | 118µs | # spent 122µs (4+118) within Archive::Zip::NewFileMember::BEGIN@11 which was called:
# once (4µs+118µs) by Spreadsheet::ParseXLSX::BEGIN@11 at line 15 # spent 118µs making 1 call to Exporter::import |
| 12 | :CONSTANTS | ||||
| 13 | :ERROR_CODES | ||||
| 14 | :UTILITY_METHODS | ||||
| 15 | 1 | 210µs | 1 | 122µs | ); # spent 122µs making 1 call to Archive::Zip::NewFileMember::BEGIN@11 |
| 16 | |||||
| 17 | # Given a file name, set up for eventual writing. | ||||
| 18 | sub _newFromFileNamed { | ||||
| 19 | my $class = shift; | ||||
| 20 | my $fileName = shift; # local FS format | ||||
| 21 | my $newName = shift; | ||||
| 22 | $newName = _asZipDirName($fileName) unless defined($newName); | ||||
| 23 | return undef unless (stat($fileName) && -r _ && !-d _ ); | ||||
| 24 | my $self = $class->new(@_); | ||||
| 25 | $self->{'fileName'} = $newName; | ||||
| 26 | $self->{'externalFileName'} = $fileName; | ||||
| 27 | $self->{'compressionMethod'} = COMPRESSION_STORED; | ||||
| 28 | my @stat = stat(_); | ||||
| 29 | $self->{'compressedSize'} = $self->{'uncompressedSize'} = $stat[7]; | ||||
| 30 | $self->desiredCompressionMethod( | ||||
| 31 | ($self->compressedSize() > 0) | ||||
| 32 | ? COMPRESSION_DEFLATED | ||||
| 33 | : COMPRESSION_STORED | ||||
| 34 | ); | ||||
| 35 | $self->unixFileAttributes($stat[2]); | ||||
| 36 | $self->setLastModFileDateTimeFromUnix($stat[9]); | ||||
| 37 | $self->isTextFile(-T _ ); | ||||
| 38 | return $self; | ||||
| 39 | } | ||||
| 40 | |||||
| 41 | sub rewindData { | ||||
| 42 | my $self = shift; | ||||
| 43 | |||||
| 44 | my $status = $self->SUPER::rewindData(@_); | ||||
| 45 | return $status unless $status == AZ_OK; | ||||
| 46 | |||||
| 47 | return AZ_IO_ERROR unless $self->fh(); | ||||
| 48 | $self->fh()->clearerr(); | ||||
| 49 | $self->fh()->seek(0, IO::Seekable::SEEK_SET) | ||||
| 50 | or return _ioError("rewinding", $self->externalFileName()); | ||||
| 51 | return AZ_OK; | ||||
| 52 | } | ||||
| 53 | |||||
| 54 | # Return bytes read. Note that first parameter is a ref to a buffer. | ||||
| 55 | # my $data; | ||||
| 56 | # my ( $bytesRead, $status) = $self->readRawChunk( \$data, $chunkSize ); | ||||
| 57 | sub _readRawChunk { | ||||
| 58 | my ($self, $dataRef, $chunkSize) = @_; | ||||
| 59 | return (0, AZ_OK) unless $chunkSize; | ||||
| 60 | my $bytesRead = $self->fh()->read($$dataRef, $chunkSize) | ||||
| 61 | or return (0, _ioError("reading data")); | ||||
| 62 | return ($bytesRead, AZ_OK); | ||||
| 63 | } | ||||
| 64 | |||||
| 65 | # If I already exist, extraction is a no-op. | ||||
| 66 | sub extractToFileNamed { | ||||
| 67 | my $self = shift; | ||||
| 68 | my $name = shift; # local FS name | ||||
| 69 | if (File::Spec->rel2abs($name) eq | ||||
| 70 | File::Spec->rel2abs($self->externalFileName()) and -r $name) { | ||||
| 71 | return AZ_OK; | ||||
| 72 | } else { | ||||
| 73 | return $self->SUPER::extractToFileNamed($name, @_); | ||||
| 74 | } | ||||
| 75 | } | ||||
| 76 | |||||
| 77 | 1 | 2µs | 1; |