--- cf.schmorp.de/server/utils/cfutil.in 2007/06/10 02:51:46 1.36 +++ cf.schmorp.de/server/utils/cfutil.in 2007/07/10 16:24:00 1.37 @@ -103,14 +103,16 @@ { our %ANIMINFO; our %FACEINFO; + our %RESOURCE; our @ARC; our %ARC; our $TRS; our $NFILE; + our $PATH; our $QUANTIZE = "+dither -colorspace RGB -colors 256"; - our (@png, @trs, @arc); # files we are interested in + our (@png, @trs, @arc, @res); # files we are interested in sub commit_png($$$) { my ($name, $data, $T) = @_; @@ -385,6 +387,30 @@ } } + sub process_res { + while (@res) { + my ($dir, $file) = @{pop @res}; + + my $data; + aio_load "$dir/$file", $data; + + $file =~ s/\.res$//; + $file =~ /\.([^.]+)$/ + or next; + + my $type = $1; + + substr $dir, 0, 1 + length $PATH, ""; + + $RESOURCE{"$dir/$file"} = { + type => $1, + copyright => "", # TODO + data => $data, + chksum => Digest::MD5::md5 $data, + }; + } + } + sub find_files; sub find_files { my ($path) = @_; @@ -403,6 +429,8 @@ push @trs, [$path, $file]; } elsif ($file =~ /\.arc$/) { push @arc, [$path, $file]; + } elsif ($file =~ /\.(ogg|res)$/) { + push @res, [$path, $file]; } else { warn "ignoring $path/$file\n" if $VERBOSE >= 3; } @@ -413,6 +441,8 @@ sub inst_arch($) { my (undef, $path) = @_; + $PATH = $path; + print "\n", "Installing '$path' to '$DATADIR'\n", "\n", @@ -436,6 +466,7 @@ (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_trs), (async \&process_trs), (async \&process_arc), (async \&process_arc), + (async \&process_res), (async \&process_res), ); { @@ -513,6 +544,7 @@ version => 2, faceinfo => \%FACEINFO, animinfo => \%ANIMINFO, + resource => \%RESOURCE, }; }