common/tools/detectArchiveCollisions.pl
changeset 1303 77ff148fa4d2
equal deleted inserted replaced
1302:13e40df94492 1303:77ff148fa4d2
       
     1 #!perl -w
       
     2 # Copyright (c) 2010 Symbian Foundation Ltd
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of the License "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Symbian Foundation Ltd - initial contribution.
       
    10 # 
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # Identify collisions between file archives
       
    15 #
       
    16 # Usage:
       
    17 # detectArchiveCollisions.pl this.zip that.zip several_*.zip and\also_*.7z
       
    18 
       
    19 use strict;
       
    20 
       
    21 # Expand shell wildcards
       
    22 @ARGV = map { glob $_ } @ARGV;
       
    23 
       
    24 my $data;
       
    25 
       
    26 foreach my $archive (@ARGV)
       
    27 {
       
    28 	print "Reading $archive...\n";
       
    29 	my $file = undef;
       
    30 	foreach my $line (`7z l -slt $archive`)
       
    31 	{
       
    32 		if ($line =~ m{^Path = (.*)})
       
    33 		{
       
    34 			$file = $1;
       
    35 			next;
       
    36 		}
       
    37 
       
    38 		if ($line =~ m{^Folder = -})
       
    39 		{
       
    40 			# Record this (non-directory) item
       
    41 			push @{$data->{$file}}, $archive;
       
    42 			next;
       
    43 		}
       
    44 	}
       
    45 }
       
    46 
       
    47 foreach my $file (sort keys %$data)
       
    48 {
       
    49 	next unless scalar @{$data->{$file}} > 1;
       
    50 	print "ERROR: $file\n";
       
    51 	foreach (@{$data->{$file}})
       
    52 	{
       
    53 		print "\t$_\n";
       
    54 	}
       
    55 }
       
    56