Fuse-Filesys-Virtual
view release on metacpan or search on metacpan
lib/Fuse/Filesys/Virtual.pm view on Meta::CPAN
=head2 unlink
Same as Fuse.
=cut
sub unlink {
my $self = shift;
my ($fname) = @_;
my $busy = eval {
return -EBUSY() if ($self->{_cache}->is_busy($fname));
};
return $busy if ($busy);
eval {
unless ($self->{_filesys}->delete($fname)) {
$! = EPERM;
die "failure";
}
};
if ($@) {
$self->_debug($@);
$! = EPERM if ($! == 0);
lib/Fuse/Filesys/Virtual.pm view on Meta::CPAN
=head2 rmdir
Same as Fuse.
=cut
sub rmdir {
my $self = shift;
my ($dirname) = @_;
my $busy = eval {
return -EBUSY() if ($self->{_cache}->is_busy($dirname));
};
return $busy if ($busy);
eval {
$self->{_filesys}->rmdir($dirname);
};
if ($@) {
$self->_debug($@);
$! = EPERM if ($! == 0);
return -$!;
}
lib/Fuse/Filesys/Virtual.pm view on Meta::CPAN
Same as Fuse.
But his function is implemented by Copy & Delete.
=cut
sub rename {
my $self = shift;
my ($oldname, $newname) = @_;
my $busy = eval {
return -EBUSY() if ($self->{_cache}->is_busy($oldname));
};
return $busy if ($busy);
$busy = eval {
return -EBUSY() if (!$self->{_filesys}->test('d', $newname)
&& $self->{_cache}->is_busy($newname));
};
return $busy if ($busy);
eval {
$self->{_filesys}->rename($oldname, $newname)
or die "cannot rename: $!";
};
if ($@) {
$self->_debug($@);
$! = EPERM if ($! == 0);
return -$!;
}
lib/Fuse/Filesys/Virtual/HandleCache.pm view on Meta::CPAN
my $class = shift;
my ($filesys) = shift;
bless {
_filesys => $filesys,
_read => {},
_write => {},
}, $class;
}
=head2 is_busy
returns file or directory is used or not.
=cut
sub is_busy {
my $self = shift;
my ($fname) = @_;
return 1 if ($self->{_read}->{$fname});
return 1 if ($self->{_write}->{$fname});
# directory is busy?
for (keys %{$self->{_read}}, keys %{$self->{_write}}) {
return 1 if (/^\Q$fname\E\//);
}
return undef;
}
sub _file_exist {
my $self = shift;
my ($fname) = @_;
t/plain-lock.t view on Meta::CPAN
#
# Tests using Filesys::Virtual::Plain
#
# file is busy while using
#
use strict;
use Test::More tests => 15;
use Cwd;
use File::Path;
use POSIX qw(:errno_h :fcntl_h);
( run in 0.239 second using v1.01-cache-2.11-cpan-87723dcf8b7 )