| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
# show sorted content of zip archive with date+time, size and file name |
| 4 |
# surpress superflous informations |
| 5 |
|
| 6 |
$0 =~ s:.*/::; |
| 7 |
|
| 8 |
$usage = "usage: $0 file.7z\n"; |
| 9 |
die $usage if scalar(@ARGV) != 1 or "@ARGV" =~ /^-/; |
| 10 |
|
| 11 |
$file = shift @ARGV; |
| 12 |
|
| 13 |
die "$0: \"$file\" does not exist\n" unless -e $file; |
| 14 |
die "$0: \"$file\" is not a regular file\n" unless -f $file; |
| 15 |
die "$0: \"$file\" is not readable\n" unless -r $file; |
| 16 |
|
| 17 |
open $list,'-|',qw'unzip -l',$file or exit $?; |
| 18 |
|
| 19 |
# default table columns and lengths |
| 20 |
$r1s = 20; |
| 21 |
$r1l = 6; |
| 22 |
$r2s = 39; |
| 23 |
$r2l = 14; |
| 24 |
|
| 25 |
$_ = <$list>; |
| 26 |
$_ = <$list>; print; |
| 27 |
$_ = <$list>; print; |
| 28 |
while (<$list>) { |
| 29 |
if (/^( *\d+ [\d-]+ \d\d:\d\d (.+)\n)/) { |
| 30 |
$list{$2} = $1; |
| 31 |
} |
| 32 |
if (/^--/) { |
| 33 |
foreach my $file (sort { lc $a cmp lc $b } keys %list) { |
| 34 |
print $list{$file} |
| 35 |
} |
| 36 |
print; |
| 37 |
$_ = <$list>; print; |
| 38 |
exit; |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
$_ = <$list>; |
| 43 |
&reduce; |
| 44 |
print; |
| 45 |
|
| 46 |
while (<$list>) { |
| 47 |
s:$:/: if substr($_,$r1s,1) eq 'D'; |
| 48 |
$file = substr($_,$r2s+$r2l,999); |
| 49 |
&reduce; |
| 50 |
if (/^---/) { |
| 51 |
$tail = $_; |
| 52 |
last; |
| 53 |
} |
| 54 |
$list{$file} = $_; |
| 55 |
} |
| 56 |
|
| 57 |
$_ = <$list>; |
| 58 |
&reduce; |
| 59 |
$tail .= $_; |
| 60 |
|
| 61 |
foreach $file (sort keys %list) { |
| 62 |
print $list{$file}; |
| 63 |
} |
| 64 |
|
| 65 |
print $tail; |
| 66 |
|
| 67 |
sub reduce { |
| 68 |
substr($_,$r2s,$r2l) = ''; # delete Compressed column |
| 69 |
substr($_,$r1s,$r1l) = ''; # delete Attr column |
| 70 |
} |