ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra/bin/cfarch-normalize
Revision: 1.6
Committed: Tue Feb 6 23:53:27 2007 UTC (17 years, 3 months ago) by root
Branch: MAIN
CVS Tags: rel-0_97, rel-0_98, rel-0_99, rel-1_11, rel-1_13, rel-1_12, rel-2_2, rel-2_0, rel-2_1, rel-1_1, rel-1_0
Changes since 1.5: +1 -0 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/opt/bin/perl
2
3 use Crossfire;
4
5 load_archetypes;
6
7 for my $path (@ARGV) {
8 eval {
9 {
10 open my $fh, "<:raw:perlio:utf8", $path
11 or die "$path: $!\n";
12
13 sysread $fh, my $buf, 8192;
14 $buf =~ /^Object \S+\n.*^end$/ism
15 or die "$path: not a crossfire arch file\n";
16 }
17
18 my $arch = read_arch ($path);
19
20 $arch = [
21 map $arch->{$_},
22 sort keys %$arch
23 ];
24
25 open my $fh, ">:raw:utf8", "$path~" or Carp::croak "$path~: $!";
26 print $fh Crossfire::archlist_to_string ($arch)
27 or Carp::croak "$path~: $!";
28 close $fh or Carp::croak "$path~: $!";
29 rename "$path~", $path;
30
31 1
32 } or warn $@;
33 }
34