author | Maciej Seroka <maciejs@symbian.org> |
Mon, 23 Nov 2009 09:08:01 +0000 | |
changeset 787 | bfafbde70ba1 |
parent 108 | d33d43677cdf |
permissions | -rw-r--r-- |
39
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
1 |
#!perl -w |
108 | 2 |
# Copyright (c) 2009 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 |
# Recursive listing of a directory, outputting lower-cased relative paths with unix dir separators |
|
15 |
||
39
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
16 |
use strict; |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
17 |
|
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
18 |
my $dir = shift or die "Usage: $0 <dir> \n"; # provided dir to traverse |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
19 |
my $filelist = []; |
78
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
39
diff
changeset
|
20 |
my $init = $dir = lc($dir); |
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
39
diff
changeset
|
21 |
$init =~ s{\\}{\\\\}; |
39
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
22 |
|
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
23 |
# fwd declaration to prevent warning |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
24 |
sub recursedir($$); |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
25 |
|
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
26 |
# run recurse and print |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
27 |
recursedir ($dir, $filelist); |
78
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
39
diff
changeset
|
28 |
|
39
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
29 |
print $_, "\n" for(@$filelist); |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
30 |
|
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
31 |
sub recursedir($$) { |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
32 |
|
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
33 |
my $dir = shift @_; |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
34 |
my $list = shift @_; |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
35 |
|
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
36 |
if(opendir(DIR, "$dir")) { |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
37 |
# list dir |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
38 |
for my $file(grep { !/^\./ } readdir DIR) { |
78
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
39
diff
changeset
|
39 |
if(-d "$dir/$file") { |
39
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
40 |
# traverse subdirs |
78
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
39
diff
changeset
|
41 |
recursedir("$dir/$file", $list); |
39
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
42 |
} |
78
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
39
diff
changeset
|
43 |
elsif(-f "$dir/$file") { |
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
39
diff
changeset
|
44 |
my $formatted = lc($dir)."/".lc($file); |
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
39
diff
changeset
|
45 |
$formatted =~ s!$init/!!; |
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
39
diff
changeset
|
46 |
push @$list, $formatted; |
39
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
47 |
} |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
48 |
} |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
49 |
closedir DIR; |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
50 |
} |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
51 |
else { |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
52 |
warn "Cannot open the directory '$dir' $!\n"; |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
53 |
} |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
54 |
} |