sbsv1/abld/genutil/listzip.pl
author jjkang
Wed, 30 Jun 2010 11:35:58 +0800
changeset 607 378360dbbdba
parent 606 30b30f9da0b7
permissions -rw-r--r--
Merge missed changeset 11 (raptor v2.14 and helium 10.0)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
     1
#!/usr/bin/perl
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     2
# Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     3
# All rights reserved.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     4
# This component and the accompanying materials are made available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     5
# under the terms of "Eclipse Public License v1.0"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     6
# which accompanies this distribution, and is available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     8
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     9
# Initial Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    11
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    12
# Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    13
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    14
# Description:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    15
# e32toolp/genutil/listzip.pl
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    16
# Utility for listing the contents of a zip file.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    17
# Syntax:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    18
# perl listzip.pl <prefix> <zipfile>
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    19
# 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
    20
# <prefix> and is printed on a separate line.
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
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
    24
# Version
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
    25
my $MajorVersion = 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
    26
my $MinorVersion = 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
    27
my $PatchVersion = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
    28
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    29
sub _print_usage_and_die();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    30
sub _print_err_and_die(@);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    31
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    32
sub main(@)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    33
{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    34
    my ($prefix, $zipf, @junk) = @_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    35
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    36
    _print_usage_and_die() if (!$prefix || !$zipf || @junk);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    37
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    38
    _print_err_and_die("$prefix is not a directory.") unless -d $prefix;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    39
    _print_err_and_die("$zipf doesn't exist.") unless -f $zipf;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    40
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    41
    my @raw_data = qx/unzip -l $zipf/;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    42
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    43
    for (@raw_data)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    44
    {
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
    45
        if ($_ =~ /^\s*\d+\s+\d\d[-|\/|\.]\d\d[-|\/|\.]\d\d\s+\d\d:\d\d\s+(.*)/)
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    46
        {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    47
            my $line = "${prefix}/$1";
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
    48
            $line =~ s/\//\\/g if($^O =~ /^MSWin32$/i);
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    49
	    # don't print directories under the <build> tags
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
    50
	    if (!($line =~ /[\\|\/]$/)) {
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    51
		    print "$line\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    52
		    }
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    53
        }
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    54
    }
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_usage_and_die()
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    58
{
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
    59
    print "LISTZIP zip files process tool V$MajorVersion.$MinorVersion.$PatchVersion\nusage: listzip.pl <prefix> <zipfile>\n";
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    60
    exit 2;
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
sub _print_err_and_die(@)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    64
{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    65
    print "listzip.pl: error: @_\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    66
    exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    67
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    68
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    69
main(@ARGV);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    70
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    71