williamr/compare_7z_listings.pl
changeset 2 a600c1a596f7
equal deleted inserted replaced
1:4a4ca5a019bb 2:a600c1a596f7
       
     1 #!/usr/bin/perl
       
     2 
       
     3 # Copyright (c) 2009 Symbian Foundation Ltd
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of the License "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 # Symbian Foundation Ltd - initial contribution.
       
    11 # 
       
    12 # Contributors:
       
    13 #
       
    14 # Description:
       
    15 # Compare two 7z listings, looking for files present in both
       
    16 
       
    17 use strict;
       
    18 
       
    19 my %first_files;
       
    20 my $line;
       
    21 my $file_index = -1;
       
    22 
       
    23 while ($line=<>)
       
    24   {
       
    25   
       
    26   if ($line =~ /^Listing archive/)
       
    27     {
       
    28     $file_index++;
       
    29     print "$file_index: Processing $line";
       
    30     next;
       
    31     }
       
    32 
       
    33   # 2009-04-30 11:26:58 D....            0            0  epoc32\cshlpcmp_template
       
    34   # 2009-03-20 22:22:18 .....        72192        16307  epoc32\cshlpcmp_template\cshelp2000.dot
       
    35   
       
    36   next if (length($line) < 54);
       
    37   
       
    38   my $dir_attribute = substr($line, 20, 1);  
       
    39   if ($dir_attribute eq ".")
       
    40     {
       
    41     chomp $line;
       
    42     my $fullpath = substr($line, 53);
       
    43     
       
    44     if ($file_index == 0)
       
    45       {
       
    46       # first file
       
    47       $first_files{$fullpath} = $line;
       
    48       next;
       
    49       }
       
    50     if (defined $first_files{$fullpath})
       
    51       {
       
    52       print "Duplicate filename: $fullpath\n";
       
    53       print "\t$first_files{$fullpath}\n\t$line\n";
       
    54       next
       
    55       }
       
    56     }
       
    57   }
       
    58