ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra/bin/cfarch-normalize
Revision: 1.3
Committed: Tue Feb 6 22:08:14 2007 UTC (17 years, 3 months ago) by root
Branch: MAIN
Changes since 1.2: +18 -8 lines
Log Message:
*** empty log message ***

File Contents

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