--- deliantra/server/utils/cfutil.in 2007/03/06 22:07:56 1.1 +++ deliantra/server/utils/cfutil.in 2007/03/07 01:23:37 1.2 @@ -1,3 +1,184 @@ #!@PERL@ -@CONVERT@ +use strict; + +my $prefix = "@prefix@"; +my $exec_prefix = "@exec_prefix@"; +my $datarootdir = "@datarootdir@"; +my $DATADIR = "@datadir@/@PACKAGE@"; + +my $CONVERT = "@CONVERT@"; +my $IDENTIFY = "@IDENTIFY@"; +my $RSYNC = "@RSYNC@"; + +use Getopt::Long; +use IO::AIO; +use File::Temp; +use Crossfire; + +sub usage { + warn < $T || $h > $T) { + # split + } else { + # use as-is + commit_png $face, $png; + } + + #warn "$path: $w, $h\n"; + }; + }; + + IO::AIO::poll; # reduce file-handle pressure + } + + sub add_arc($$) { + my ($dir, $file) = @_; + + my $arc; + aio_load "$dir/$file", $arc, sub { # simply pre-cache, as read_arch wants a file :/ + my $arc = read_arch "$dir/$file"; + }; + } + + sub add_trs($$) { + my ($dir, $file) = @_; + } + + sub collect_arch; + sub collect_arch { + my ($path) = @_; + + aioreq_pri 4; + aio_scandir $path, 4, sub { + my ($dirs, $nondirs) = @_; + + collect_arch "$path/$_" + for grep $_ !~ /^(?:CVS|dev)$/, @$dirs; + + for my $file (@$nondirs) { + if ($file =~ /\.png$/) { + add_png "$path/$file"; + } elsif ($file =~ /\.trs$/) { + add_trs $path, $file; + } elsif ($file =~ /\.arc$/) { + add_arc $path, $file; + } else { + warn "ignoring $path/$file\n" if $VERBOSE >= 2; + } + } + }; + } + + sub inst_arch($) { + my (undef, $path) = @_; + + print "installing '$path' to '$DATADIR'\n\n"; + + if (!-d "$path/treasures") { + warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n"; + exit 1 unless $FORCE; + } + + collect_arch $path; + IO::AIO::flush; + + die "--install-arch not yet implemented\n"; + } +} + +Getopt::Long::Configure ("bundling", "no_ignore_case"); +GetOptions ( + "verbose|v:+" => \$VERBOSE, + "quiet|q" => sub { $VERBOSE = 0 }, + "force" => sub { $FORCE = 1 }, + "install-arch=s" => \&inst_arch, + "install-maps=s" => \&inst_maps, + "print-statedir" => sub { print "@pkgstatedir@\n" }, + "print-datadir" => sub { print "$DATADIR\n" }, + "print-confdir" => sub { print "@pkgconfdir@\n" }, + "print-libdir" => sub { print "@libdir@/@PACKAGE@\n" }, + "print-bindir" => sub { print "@bindir@/@PACKAGE@\n" }, +) or usage; +