lib/Fops/native.pm
changeset 0 21a87c5f86e4
child 1 9416fc33d2a0
equal deleted inserted replaced
-1:000000000000 0:21a87c5f86e4
       
     1 package Fops::native;
       
     2 use strict;
       
     3 use warnings;
       
     4 use Carp;
       
     5 use Cwd ();
       
     6 use base qw(Fops);
       
     7 
       
     8 sub new {
       
     9     my $class = ref $_[0] ? ref shift : shift;
       
    10     my $self = bless {} => $class;
       
    11     $self->{root} = shift;
       
    12     $self->{type} = "native";
       
    13 
       
    14     return $self;
       
    15 }
       
    16 
       
    17 sub cd {
       
    18     my $self = shift;
       
    19     my $dst = shift;
       
    20 
       
    21     if ($dst =~ /\//) {
       
    22 	$dst = Cwd::abs_path "$self->{root}/$dst";
       
    23     }
       
    24     else {
       
    25 	$dst = Cwd::abs_path(cwd . "/$dst");
       
    26     }
       
    27 
       
    28     croak "invalid destination $dst" 
       
    29 	if not $dst =~ /^$self->{root\/}/;
       
    30 
       
    31     chdir $dst or croak "Can't chdir to $dst: $!";
       
    32 }
       
    33 
       
    34 sub pwd { cwd }
       
    35 
       
    36 
       
    37 1;