diff -r 000000000000 -r 21a87c5f86e4 lib/Fops/native.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/Fops/native.pm Tue Aug 02 00:21:00 2011 +0200 @@ -0,0 +1,37 @@ +package Fops::native; +use strict; +use warnings; +use Carp; +use Cwd (); +use base qw(Fops); + +sub new { + my $class = ref $_[0] ? ref shift : shift; + my $self = bless {} => $class; + $self->{root} = shift; + $self->{type} = "native"; + + return $self; +} + +sub cd { + my $self = shift; + my $dst = shift; + + if ($dst =~ /\//) { + $dst = Cwd::abs_path "$self->{root}/$dst"; + } + else { + $dst = Cwd::abs_path(cwd . "/$dst"); + } + + croak "invalid destination $dst" + if not $dst =~ /^$self->{root\/}/; + + chdir $dst or croak "Can't chdir to $dst: $!"; +} + +sub pwd { cwd } + + +1;