VFSsimple::Drv::Rsync - A VFSsimple implementation over rsync protocol


VFSsimple-Drv-Rsync documentation Contained in the VFSsimple-Drv-Rsync distribution.

Index


Code Index:

NAME

Top

VFSsimple::Drv::Rsync - A VFSsimple implementation over rsync protocol

DESCRIPTION

Top

This module provide access method for VFSsimple module to access to file located on rsync server.

SEE ALSO

Top

VFSsimple

LICENSE AND COPYRIGHT

Top


VFSsimple-Drv-Rsync documentation Contained in the VFSsimple-Drv-Rsync distribution.
package VFSsimple::Drv::Rsync;

use strict;
use warnings;
use base qw(VFSsimple::Base);
use URI ();
use File::Temp qw(tempfile);

our $VERSION = '0.03';


sub drv_new {
    my ($self) = @_;
    foreach (split(':', $ENV{PATH})) {
        -x "$_/rsync" and return $self;
    }
    return;
}


sub drv_get {
    my ($self, $src) = @_;
    my (undef, $dest) = tempfile(UNLINK => 0);
    $self->drv_copy($src, $dest);
}

sub drv_copy {
    my ($self, $src, $dest) = @_;
    system('rsync', '-q', $self->{root} . '/' . $src, $dest);
    my $res = $? >> 8;
    if ($res) { return }
    return $dest;
}

sub drv_exists {
    my ($self, $file) = @_;
    system('rsync', '-q', "$self->{root}/$file");
    my $res = $? >> 8;
    return ($res eq 0);
}

1;

__END__