author | Simon Howkins <simonh@symbian.org> |
Mon, 11 May 2009 13:48:11 +0100 | |
changeset 112 | a8aa5d600806 |
parent 101 | 52cc4f7310db |
child 131 | d33d43677cdf |
permissions | -rw-r--r-- |
60
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
1 |
#!perl -w |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
2 |
use strict; |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
3 |
|
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
4 |
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
|
5 |
my $filelist = []; |
101
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
60
diff
changeset
|
6 |
my $init = $dir = lc($dir); |
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
60
diff
changeset
|
7 |
$init =~ s{\\}{\\\\}; |
60
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
8 |
|
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
9 |
# 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
|
10 |
sub recursedir($$); |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
11 |
|
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
12 |
# 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
|
13 |
recursedir ($dir, $filelist); |
101
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
60
diff
changeset
|
14 |
|
60
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
15 |
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
|
16 |
|
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
17 |
sub recursedir($$) { |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
18 |
|
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
19 |
my $dir = shift @_; |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
20 |
my $list = shift @_; |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
21 |
|
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
22 |
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
|
23 |
# list dir |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
24 |
for my $file(grep { !/^\./ } readdir DIR) { |
101
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
60
diff
changeset
|
25 |
if(-d "$dir/$file") { |
60
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
26 |
# traverse subdirs |
101
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
60
diff
changeset
|
27 |
recursedir("$dir/$file", $list); |
60
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
28 |
} |
101
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
60
diff
changeset
|
29 |
elsif(-f "$dir/$file") { |
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
60
diff
changeset
|
30 |
my $formatted = lc($dir)."/".lc($file); |
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
60
diff
changeset
|
31 |
$formatted =~ s!$init/!!; |
52cc4f7310db
Strip drive and dir root from listing
Shabe Razvi <shaber@symbian.org>
parents:
60
diff
changeset
|
32 |
push @$list, $formatted; |
60
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
33 |
} |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
34 |
} |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
35 |
closedir DIR; |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
36 |
} |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
37 |
else { |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
38 |
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
|
39 |
} |
9edae8fe1416
Add tools to create file tree deltas and integrate them into build f/w
ShabeR@UK-SHABER
parents:
diff
changeset
|
40 |
} |