App-zipdetails
view release on metacpan or search on metacpan
bin/zipdetails view on Meta::CPAN
package Eocd ;
sub new
{
my $class = shift ;
my %object = (
'zip64' => 0,
) ;
bless \%object, $class;
}
}
sub displayFileInfo
{
return;
my $filename = shift;
info undef,
"Filename : '$filename'",
"Size : " . (-s $filename) . " (" . decimalHex0x(-s $filename) . ")",
# "Native Encoding: '" . TextEncoding::getNativeLocaleName() . "'",
}
{
package TextEncoding;
my $nativeLocaleEncoding = getNativeLocale();
my $opt_EncodingFrom = $nativeLocaleEncoding;
my $opt_EncodingTo = $nativeLocaleEncoding ;
my $opt_Encoding_Enabled;
my $opt_Debug_Encoding;
my $opt_use_LanguageEncodingFlag;
sub setDefaults
{
$nativeLocaleEncoding = getNativeLocale();
$opt_EncodingFrom = $nativeLocaleEncoding;
$opt_EncodingTo = $nativeLocaleEncoding ;
$opt_Encoding_Enabled = 1;
$opt_Debug_Encoding = 0;
$opt_use_LanguageEncodingFlag = 1;
}
sub getNativeLocale
{
state $enc;
if (! defined $enc)
{
eval
{
require encoding ;
my $encoding = encoding::_get_locale_encoding() ;
if (! $encoding)
{
# CP437 is the legacy default for zip files
$encoding = 'cp437';
# ::warning undef, "Cannot determine system charset: defaulting to '$encoding'"
}
$enc = Encode::find_encoding($encoding) ;
} ;
}
return $enc;
}
sub getNativeLocaleName
{
state $name;
return $name
if defined $name ;
if (! defined $name)
{
my $enc = getNativeLocale();
if ($enc)
{
$name = $enc->name()
}
else
{
$name = 'unknown'
}
}
return $name ;
}
sub parseEncodingOption
{
my $opt_name = shift;
my $opt_value = shift;
my $enc = Encode::find_encoding($opt_value) ;
die "Encoding '$opt_value' not found for option '$opt_name'\n"
unless ref $enc;
if ($opt_name eq 'encoding')
{
$opt_EncodingFrom = $enc;
}
elsif ($opt_name eq 'output-encoding')
{
$opt_EncodingTo = $enc;
}
else
{
die "Unknown option $opt_name\n"
}
}
sub NoEncoding
{
my $opt_name = shift;
my $opt_value = shift;
$opt_Encoding_Enabled = 0 ;
bin/zipdetails view on Meta::CPAN
This program creates a detailed report on the internal structure of zip
files. For each item of metadata within a zip file the program will output
=over 5
=item the offset into the zip file where the item is located.
=item a textual representation for the item.
=item an optional hex dump of the item.
=back
The program assumes a prior understanding of the internal structure of Zip
files. You should have a copy of the zip file definition,
L<APPNOTE.TXT|https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT>,
at hand to help understand the output from this program.
=head2 Default Behaviour
By default the program expects to be given a well-formed zip file. It will
navigate the zip file by first parsing the zip C<Central Directory> at the end
of the file. If the C<Central Directory> is found, it will then walk
sequentially through the zip records starting at the beginning of the file.
See L<Advanced Analysis> for other processing options.
If the program finds any structural or portability issues with the zip file
it will print a message at the point it finds the issue and/or in a summary
at the end of the output report. Whilst the set of issues that can be
detected it exhaustive, don't assume that this program can find I<all> the
possible issues in a zip file - there are likely edge conditions that need
to be addressed.
If you have suggestions for use-cases where this could be enhanced please
consider creating an enhancement request (see L<"SUPPORT">).
=head3 Date & Time fields
Date/time fields found in zip files are displayed in local time. Use the
C<--utc> option to display these fields in Coordinated Universal Time (UTC).
=head3 Filenames & Comments
Filenames and comments are decoded/encoded using the default system
encoding of the host running C<zipdetails>. When the system encoding cannot
be determined C<cp437> will be used.
The exceptions are
=over 5
=item *
when the C<Language Encoding Flag> is set in the zip file, the
filename/comment fields are assumed to be encoded in UTF-8.
=item *
the definition for the metadata field implies UTF-8 charset encoding
=back
See L<"Filename Encoding Issues"> and L<Filename & Comment Encoding
Options> for ways to control the encoding of filename/comment fields.
=head2 OPTIONS
=head3 General Options
=over 5
=item C<-h>, C<--help>
Display help
=item C<--redact>
Obscure filenames and payload data in the output. Handy for the use case
where the zip files contains sensitive data that cannot be shared.
=item C<--scan>
Pessimistically scan the zip file looking for possible zip records. Can be
error-prone. For very large zip files this option is slow. Consider using
the C<--walk> option first. See L<"Advanced Analysis Options">
=item C<--utc>
By default, date/time fields are displayed in local time. Use this option to
display them in in Coordinated Universal Time (UTC).
=item C<-v>
Enable Verbose mode. See L<"Verbose Output">.
=item C<--version>
Display version number of the program and exit.
=item C<--walk>
Optimistically walk the zip file looking for possible zip records.
See L<"Advanced Analysis Options">
=back
=head3 Filename & Comment Encoding Options
See L<"Filename Encoding Issues">
=over 5
=item C<--encoding name>
Use encoding "name" when reading filenames/comments from the zip file.
When this option is not specified the default the system encoding is used.
=item C< --no-encoding>
( run in 1.948 second using v1.01-cache-2.11-cpan-5b529ec07f3 )