Last change
on this file since 24848 was 24848, checked in by jmt12, 12 years ago |
Extended the manifestinator to correctly recurse into directories
|
-
Property svn:executable
set to
*
|
File size:
869 bytes
|
Line | |
---|
1 | #!/usr/bin/perl
|
---|
2 |
|
---|
3 | use strict;
|
---|
4 |
|
---|
5 | if (!defined $ARGV[0] || !-d $ARGV[0])
|
---|
6 | {
|
---|
7 | print "usage: manifestinator.pl <import directory>\n";
|
---|
8 | exit(0);
|
---|
9 | }
|
---|
10 |
|
---|
11 | open(XMLOUT, '>:utf8', 'manifest.xml');
|
---|
12 | print XMLOUT "<Manifest>\n";
|
---|
13 | print XMLOUT " <Index>\n";
|
---|
14 |
|
---|
15 | &manifestify($ARGV[0], '');
|
---|
16 |
|
---|
17 | print XMLOUT " </Index>\n";
|
---|
18 | print XMLOUT "</Manifest>\n";
|
---|
19 |
|
---|
20 | close(XMLOUT);
|
---|
21 | exit;
|
---|
22 |
|
---|
23 | sub manifestify
|
---|
24 | {
|
---|
25 | my ($dir, $prefix) = @_;
|
---|
26 | if (!opendir(DH, $dir))
|
---|
27 | {
|
---|
28 | die ("Failed to open import directory for reading!\n");
|
---|
29 | }
|
---|
30 | my @files = readdir(DH);
|
---|
31 | closedir(DH);
|
---|
32 | foreach my $file (sort @files)
|
---|
33 | {
|
---|
34 | if ($file =~ /^\./)
|
---|
35 | {
|
---|
36 | next;
|
---|
37 | }
|
---|
38 | my $path = $dir . '/' . $file;
|
---|
39 | if (-d $path)
|
---|
40 | {
|
---|
41 | my $new_prefix = $prefix . $file . '/';
|
---|
42 | &manifestify($path, $new_prefix);
|
---|
43 | }
|
---|
44 | else
|
---|
45 | {
|
---|
46 | print XMLOUT " <Filename>" . $prefix . $file . "</Filename>\n";
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.