| Revision: | 1.1.1.1 (vendor branch) |
| Committed: | Sat Feb 4 23:55:29 2006 UTC (19 years, 11 months ago) by root |
| Content type: | text/plain |
| Branch: | UPSTREAM, MAIN |
| CVS Tags: | post_fixaltar, last_stable, post_fixaltar2, rel-2_82, rel-2_81, rel-2_80, pre_coinconvert, UPSTREAM_2006_03_15, rel-3_0, rel-2_6, rel-2_7, rel-2_4, rel-2_5, rel-2_2, rel-2_0, rel-2_1, rel-2_72, rel-2_73, rel-2_71, rel-2_76, rel-2_77, rel-2_74, rel-2_75, rel-2_54, rel-2_55, rel-2_56, rel-2_79, UPSTREAM_2006_02_01, rel-2_53, pre_material_cfarch_normalize_run, rel-2_32, pre_fixconverter, post_coinconvert, pre_fixaltar2, pre_map_rename, UPSTREAM_2006_02_22, rel-2_90, rel-2_92, rel-2_93, rel-2_78, post_fixconverter, pre_fixaltar, rel-2_61, rel-2_43, rel-2_42, rel-2_41, HEAD |
| Changes since 1.1: | +0 -0 lines |
| Log Message: | Initial Import |
| # | Content |
|---|---|
| 1 | #!/usr/bin/perl |
| 2 | # |
| 3 | # This script goes and fixes the *_style names for random maps. |
| 4 | # It is aimed at the mlab maps. the original mlab maps used |
| 5 | # uppercase file names, which were quite ugly, and also put the |
| 6 | # new styles with old styles, which isn't good when it comes to |
| 7 | # random styles. Instead, I put those style maps into their own |
| 8 | # subdirectory so they should only show up on mlab maps. |
| 9 | # |
| 10 | |
| 11 | &maplist("."); |
| 12 | |
| 13 | while ($file = shift (@maps)) { |
| 14 | &updatemap; |
| 15 | } |
| 16 | |
| 17 | |
| 18 | exit; |
| 19 | |
| 20 | # return table containing all objects in the map |
| 21 | sub updatemap { |
| 22 | local ($m, $made_change=0); |
| 23 | $last = ""; |
| 24 | $parent = ""; |
| 25 | |
| 26 | if (! open (IN, $file)) { |
| 27 | print "Can't open map file $file\n"; |
| 28 | return; |
| 29 | } |
| 30 | if (! open(OUT, ">$file.new")) { |
| 31 | print "Can't open output file $file.new\n"; |
| 32 | return; |
| 33 | } |
| 34 | if ($VERBOSE) { |
| 35 | print "Testing $file, "; |
| 36 | } |
| 37 | while (<IN>) { |
| 38 | if (/(.*style) (MLAB.*)/) { |
| 39 | $style= $1 . "style"; |
| 40 | $dest = "mlab/" . $2; |
| 41 | $dest =~ tr /A-Z/a-z/; |
| 42 | print OUT "$style $dest\n"; |
| 43 | $made_change=1; |
| 44 | } else { |
| 45 | print OUT $_; |
| 46 | } |
| 47 | } # while <IN> LOOP |
| 48 | close (IN); |
| 49 | close(OUT); |
| 50 | if ($made_change) { |
| 51 | print "$file has changed\n"; |
| 52 | unlink($file); |
| 53 | rename("$file.new", $file); |
| 54 | } |
| 55 | else { |
| 56 | unlink("$file.new"); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | # @maps contains all filenames |
| 61 | sub maplist { |
| 62 | local ($dir, $file, @dirs) = shift; |
| 63 | |
| 64 | opendir (DIR , $dir) || die "Can't open directory : $dir\n"; |
| 65 | while ($file = readdir (DIR)) { |
| 66 | next if ($file eq "." || $file eq ".." || $file eq "CVS"); |
| 67 | |
| 68 | $file = "$dir/$file"; |
| 69 | next if (-l $file); # don't process symbolic links |
| 70 | push (@dirs, $file) if (-d $file); |
| 71 | push (@maps, $file) if (-f $file); |
| 72 | } |
| 73 | closedir (DIR); |
| 74 | |
| 75 | # recursive handle sub-dirs too |
| 76 | while ($_ = shift @dirs) { |
| 77 | &maplist ($_); |
| 78 | } |
| 79 | } |
| 80 |