ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra/bin/cfarch-normalize
Revision: 1.4
Committed: Tue Feb 6 22:27:44 2007 UTC (17 years, 3 months ago) by root
Branch: MAIN
Changes since 1.3: +1 -1 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     $buf =~ /^Object \S+\n.*^end$/ism
15     or die "$path: not a crossfire arch file\n";
16     }
17 elmex 1.1
18     my $arch = read_arch ($path);
19 root 1.3 $arch = [
20     map $arch->{$_},
21     sort keys %$arch
22     ];
23 root 1.4 use Data::Dumper; warn Dumper $arch;#d#
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