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

# 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 warn $buf;
15 $buf =~ /^Object \S+\n.*^end$/ism
16 or die "$path: not a crossfire arch file\n";
17 }
18
19 my $arch = read_arch ($path);
20 $arch = [
21 map $arch->{$_},
22 sort keys %$arch
23 ];
24
25 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 rename "$path~", $path;
32
33 1
34 } or warn $@;
35 }
36