sbsv1/abld/genutil/listzip.pl
author jjkang
Fri, 25 Jun 2010 18:11:34 +0800
changeset 600 6d08f4a05d93
parent 599 fa7a3cc6effd
child 606 30b30f9da0b7
permissions -rw-r--r--
add deprecated files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     4
# under the terms of "Eclipse Public License v1.0"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     7
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    10
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    12
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    13
# Description:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    14
# e32toolp/genutil/listzip.pl
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    15
# Utility for listing the contents of a zip file.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    16
# Syntax:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    17
# perl listzip.pl <prefix> <zipfile>
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    18
# This command will print all files in the <zipfile>. Each file name is prefixed by
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    19
# <prefix> and is printed on a separate line.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    20
# 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    21
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    22
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    23
sub _print_usage_and_die();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    24
sub _print_err_and_die(@);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    25
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    26
sub main(@)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    27
{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    28
    my ($prefix, $zipf, @junk) = @_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    29
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    30
    _print_usage_and_die() if (!$prefix || !$zipf || @junk);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    31
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    32
    _print_err_and_die("$prefix is not a directory.") unless -d $prefix;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    33
    _print_err_and_die("$zipf doesn't exist.") unless -f $zipf;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    34
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    35
    my @raw_data = qx/unzip -l $zipf/;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    36
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    37
    for (@raw_data)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    38
    {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    39
        if ($_ =~ /^\s*\d+\s+\d\d[-|\/]\d\d[-|\/]\d\d\s+\d\d:\d\d\s+(.*)/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    40
        {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    41
            my $line = "${prefix}/$1";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    42
            $line =~ s/\//\\/g;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    43
	    # don't print directories under the <build> tags
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    44
	    if (!($line =~ /\\$/)) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    45
		    print "$line\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    46
		    }
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    47
        }
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    48
    }
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    49
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    50
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    51
sub _print_usage_and_die()
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    52
{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    53
    print "usage: listzip.pl <prefix> <zipfile>\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    54
    exit 2;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    55
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    56
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    57
sub _print_err_and_die(@)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    58
{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    59
    print "listzip.pl: error: @_\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    60
    exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    61
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    62
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    63
main(@ARGV);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    64
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    65