--- deliantra/Deliantra-Client/DC/DB.pm 2007/08/06 02:11:45 1.15 +++ deliantra/Deliantra-Client/DC/DB.pm 2007/08/06 05:06:33 1.16 @@ -53,6 +53,10 @@ CFPlus::DB::Server::req (unlink => @_); } +sub read_file($$) { + CFPlus::DB::Server::req (read_file => @_); +} + sub write_file($$$) { CFPlus::DB::Server::req (write_file => @_); } @@ -276,24 +280,35 @@ unlink $_[0]; } +sub do_read_file { + my ($path) = @_; + + utf8::downgrade $path; + open my $fh, "<:raw", $path + or return; + sysread $fh, my $buf, -s $fh; + + $buf +} + sub do_write_file { - my ($file, $data) = @_; + my ($path, $data) = @_; - utf8::downgrade $file; + utf8::downgrade $path; utf8::downgrade $data; - open my $fh, ">:raw", $file + open my $fh, ">:raw", $path or return; - print $fh $data; + syswrite $fh, $data; close $fh; 1 } sub do_prefetch_file { - my ($file, $size) = @_; + my ($path, $size) = @_; - utf8::downgrade $file; - open my $fh, "<:raw", $file + utf8::downgrade $path; + open my $fh, "<:raw", $path or return; sysread $fh, my $buf, $size;