source: gs2-extensions/parallel-building/trunk/src/bin/script/manifestinator.pl@ 24848

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
3use strict;
4
5if (!defined $ARGV[0] || !-d $ARGV[0])
6{
7 print "usage: manifestinator.pl <import directory>\n";
8 exit(0);
9}
10
11open(XMLOUT, '>:utf8', 'manifest.xml');
12print XMLOUT "<Manifest>\n";
13print XMLOUT " <Index>\n";
14
15&manifestify($ARGV[0], '');
16
17print XMLOUT " </Index>\n";
18print XMLOUT "</Manifest>\n";
19
20close(XMLOUT);
21exit;
22
23sub 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.