git-svn-id: https://scorched3d.svn.sourceforge.net/svnroot/scorched3d/trunk/scorched...
[scorched3d/parasti.git] / scripts / removeMSPragma.pl
blob1c547390841de580cb4a9a8acca9228f6ed54014
1 use strict;
3 my @dirs =
5 "3dsparse",
6 "common",
7 "coms",
8 "dialogs",
9 "engine",
10 "GLEXT",
11 "GLW",
12 "landscape",
13 "landscapedef",
14 "client",
15 "server",
16 "actions",
17 "cgext",
18 "scorched",
19 "sprites",
20 "tankai",
21 "target",
22 "XML",
23 "ships",
24 "tankgraph",
25 "tank",
26 "boids",
27 "placement",
28 "sound",
29 "weapons"
32 my $dir;
33 foreach $dir (@dirs)
35 opendir(IN, "../src/$dir") || die "ERROR: DIR \"$dir\"";
36 my @files = grep { /\.h/ } readdir(IN);
37 closedir(IN);
39 my $file;
40 foreach $file (@files)
42 open (INFILE, "../src/$dir/$file") || die "ERROR: File \"../$dir/$file\"";
43 my @filelines = <INFILE>;
44 close (INFILE);
46 my $index = -1;
47 for (my $i=0; $i<=$#filelines; $i++)
49 if ($filelines[$i] =~ /pragma once/)
51 $index = $i;
55 if ($index != -1)
57 my $incline = "__INCLUDE_".$file."_INCLUDE__";
58 $incline =~ s/\.//g;
60 print "$dir/$file\n";
62 $filelines[$index] = "#if !defined($incline)\n#define $incline\n";
63 push @filelines, "\n#endif // $incline\n";
65 open(OUTFILE, ">../src/$dir/$file") || die "ERROR: Out $file";
66 print OUTFILE @filelines;
67 close (OUTFILE);