|
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 # Turn a 7z listing into a manifest file that can be re-used by 7z |
|
16 # - Assumes that header/footer is fixed, and that file listing starts at column 53 |
|
17 # Also allows use on a zipfile directly by passing -z as an option |
|
18 |
|
19 use strict; |
|
20 |
|
21 my $line; |
|
22 my $between_header_footer = 0; |
|
23 my $header_footer_pattern = "------------------- ----- ------------ ------------ ------------------------"; |
|
24 |
|
25 my $file = shift or die "Usage: $0 <7z list output file> [-z to run directly on a zipfile]\n"; # provided 7z list to process |
|
26 my $mode = shift; |
|
27 |
|
28 # if -z has been specified, then generate intermediate 7z list file for processing |
|
29 if ($mode eq lc("-z")) { |
|
30 system("7z l $file > $file.tmp.lst"); |
|
31 $file = $file.".tmp.lst"; |
|
32 } |
|
33 |
|
34 open my $sevenZfile, "<", $file or die; |
|
35 |
|
36 while ($line =<$sevenZfile>) |
|
37 { |
|
38 if ($line =~ /$header_footer_pattern/) |
|
39 { |
|
40 $between_header_footer= !$between_header_footer; |
|
41 |
|
42 } |
|
43 if (($line =~ /^(.{53})(.*)/) && ($line !=/$header_footer_pattern/)) |
|
44 { |
|
45 print $2 ."\n" if $between_header_footer; |
|
46 next; |
|
47 } |
|
48 } |
|
49 |
|
50 close $sevenZfile; |
|
51 |
|
52 # remove temp 7z file if one has been generated |
|
53 if ($mode eq lc("-z")) { |
|
54 system("del $file"); |
|
55 } |
|
56 |
|
57 exit 0; |