Fuse-Filesys-Virtual

 view release on metacpan or  search on metacpan

lib/Fuse/Filesys/Virtual.pm  view on Meta::CPAN


=head2 rename

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 -$!;
    }

    return 0;
}

=head2 link

Always returns -EPERM.
This function is not supported by Virtual::Filesys.

=cut

sub link {
    my $self = shift;
    return -EPERM();
}

=head2 chmod

Always returns 0(success), but nothing is done.
This function is not supported by Virtual::Filesys.

=cut

sub chmod {
    my $self = shift;
    return 0;
}

=head2 chown

Always returns -EPERM.
This function is not supported by Virtual::Filesys.

=cut

sub chown {
    my $self = shift;
    return -EPERM();
}

=head2 truncate

Always returns -EPERM.
This function is not supported by Virtual::Filesys.

=cut

sub truncate {
    my $self = shift;
    my ($fname) = @_;

    eval {
	$self->{_cache}->truncate($fname);
    };
    if ($@) {
	$self->_debug($@);
	$! = EPERM if ($! == 0);
	return -$!;
    }

    return 0;
}

=head2 utime

Same as Fuse.

=cut

sub utime {
    my $self = shift;
    my ($fname, $atime, $mtime) = @_;

    eval {
	$self->{_filesys}->utime($atime, $mtime, $fname);
    };
    if ($@) {
	$self->_debug($@);
	$! = EPERM if ($! == 0);
	return -$!;
    }

    return 0;
}

=head2 open

Same as Fuse.

=cut

sub open {
    my $self = shift;
    my ($fname, $flags) = @_;

    my $ret = eval {



( run in 2.599 seconds using v1.01-cache-2.11-cpan-71847e10f99 )