14 |
use Data::Dumper; |
use Data::Dumper; |
15 |
|
|
16 |
|
|
17 |
our $VERSION = '0.01'; |
our $VERSION = '0.02'; |
18 |
|
|
19 |
=head1 NAME |
=head1 NAME |
20 |
|
|
86 |
$dbh = DBI->connect($arg->{'dsn'},$arg->{'user'},$arg->{'password'}, { AutoCommit => 0 }) || die $DBI::errstr; |
$dbh = DBI->connect($arg->{'dsn'},$arg->{'user'},$arg->{'password'}, { AutoCommit => 0 }) || die $DBI::errstr; |
87 |
|
|
88 |
print "start transaction\n"; |
print "start transaction\n"; |
89 |
#$dbh->begin_work || die $dbh->errstr; |
$dbh->begin_work || die $dbh->errstr; |
90 |
|
|
91 |
$sth->{filenames} = $dbh->prepare($arg->{'filenames'}) || die $dbh->errstr(); |
$sth->{filenames} = $dbh->prepare($arg->{'filenames'}) || die $dbh->errstr(); |
92 |
|
|
324 |
|
|
325 |
sub e_write { |
sub e_write { |
326 |
my $file = filename_fixup(shift); |
my $file = filename_fixup(shift); |
327 |
my ($buf_len,$off) = @_; |
my ($buffer,$off) = @_; |
328 |
|
|
329 |
return -ENOENT() unless exists($files{$file}); |
return -ENOENT() unless exists($files{$file}); |
330 |
|
|
331 |
my $len = length($files{$file}{cont}); |
my $cont = $files{$file}{cont}; |
332 |
|
my $len = length($cont); |
333 |
|
|
334 |
print "write '$file' [$len bytes] offset $off length\n"; |
print "write '$file' [$len bytes] offset $off length ",length($buffer),"\n"; |
335 |
|
|
336 |
$files{$file}{cont} = |
$files{$file}{cont} = ""; |
337 |
substr($files{$file}{cont},0,$off) . |
|
338 |
$buf_len . |
$files{$file}{cont} .= substr($cont,0,$off) if ($off > 0); |
339 |
substr($files{$file}{cont},$off+length($buf_len)); |
$files{$file}{cont} .= $buffer; |
340 |
|
$files{$file}{cont} .= substr($cont,-($off+length($buffer))) if ($off+length($buffer) > $len); |
341 |
|
|
342 |
|
$files{$file}{size} = length($files{$file}{cont}); |
343 |
|
|
344 |
if (! update_db($file)) { |
if (! update_db($file)) { |
345 |
return -ENOSYS(); |
return -ENOSYS(); |
346 |
} else { |
} else { |
347 |
return length($buf_len); |
return length($buffer); |
348 |
} |
} |
349 |
} |
} |
350 |
|
|
352 |
my $file = filename_fixup(shift); |
my $file = filename_fixup(shift); |
353 |
my $size = shift; |
my $size = shift; |
354 |
|
|
355 |
|
print "truncate to $size\n"; |
356 |
|
|
357 |
$files{$file}{cont} = substr($files{$file}{cont},0,$size); |
$files{$file}{cont} = substr($files{$file}{cont},0,$size); |
358 |
|
$files{$file}{size} = $size; |
359 |
return 0 |
return 0 |
360 |
}; |
}; |
361 |
|
|