606
|
1 |
#!/usr/bin/perl
|
599
|
2 |
# Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
# e32toolp/genutil/listzip.pl
|
|
16 |
# Utility for listing the contents of a zip file.
|
|
17 |
# Syntax:
|
|
18 |
# perl listzip.pl <prefix> <zipfile>
|
|
19 |
# This command will print all files in the <zipfile>. Each file name is prefixed by
|
|
20 |
# <prefix> and is printed on a separate line.
|
|
21 |
#
|
|
22 |
#
|
|
23 |
|
606
|
24 |
# Version
|
|
25 |
my $MajorVersion = 1;
|
|
26 |
my $MinorVersion = 1;
|
|
27 |
my $PatchVersion = 0;
|
|
28 |
|
599
|
29 |
sub _print_usage_and_die();
|
|
30 |
sub _print_err_and_die(@);
|
|
31 |
|
|
32 |
sub main(@)
|
|
33 |
{
|
|
34 |
my ($prefix, $zipf, @junk) = @_;
|
|
35 |
|
|
36 |
_print_usage_and_die() if (!$prefix || !$zipf || @junk);
|
|
37 |
|
|
38 |
_print_err_and_die("$prefix is not a directory.") unless -d $prefix;
|
|
39 |
_print_err_and_die("$zipf doesn't exist.") unless -f $zipf;
|
|
40 |
|
|
41 |
my @raw_data = qx/unzip -l $zipf/;
|
|
42 |
|
|
43 |
for (@raw_data)
|
|
44 |
{
|
606
|
45 |
if ($_ =~ /^\s*\d+\s+\d\d[-|\/|\.]\d\d[-|\/|\.]\d\d\s+\d\d:\d\d\s+(.*)/)
|
599
|
46 |
{
|
|
47 |
my $line = "${prefix}/$1";
|
606
|
48 |
$line =~ s/\//\\/g if($^O =~ /^MSWin32$/i);
|
599
|
49 |
# don't print directories under the <build> tags
|
606
|
50 |
if (!($line =~ /[\\|\/]$/)) {
|
599
|
51 |
print "$line\n";
|
|
52 |
}
|
|
53 |
}
|
|
54 |
}
|
|
55 |
}
|
|
56 |
|
|
57 |
sub _print_usage_and_die()
|
|
58 |
{
|
606
|
59 |
print "LISTZIP zip files process tool V$MajorVersion.$MinorVersion.$PatchVersion\nusage: listzip.pl <prefix> <zipfile>\n";
|
599
|
60 |
exit 2;
|
|
61 |
}
|
|
62 |
|
|
63 |
sub _print_err_and_die(@)
|
|
64 |
{
|
|
65 |
print "listzip.pl: error: @_\n";
|
|
66 |
exit 1;
|
|
67 |
}
|
|
68 |
|
|
69 |
main(@ARGV);
|
|
70 |
|
|
71 |
|