| 1 | package Lufs; | ||
| 2 | |||
| 3 | use base 'Lufs::Glue'; | ||
| 4 | use Lufs::C; | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | our $VERSION = 0.21; | ||
| 9 | |||
| 10 | use vars qw/$AUTOLOAD/; | ||
| 11 | |||
| 12 | sub new { | ||
| 13 | my $cls = shift; | ||
| 14 | my $self = {}; | ||
| 15 | bless $self => $cls; | ||
| 16 | $Lufs::C::object = $self; | ||
| 17 | } | ||
| 18 | |||
| 19 | sub _init { | ||
| 20 | my $self = shift; | ||
| 21 | my $opt = pop; | ||
| 22 | my ($f, $class) = ($opt->{host}, $opt->{host}); | ||
| 23 | $f =~ s{\.}{/}g;$f .= '.pm'; | ||
| 24 | $class =~ s{\.}{::}g; | ||
| 25 | eval "require '$f'"; | ||
| 26 | if ($@) { warn "cannot load class: $@"; return 0 } | ||
| 27 | eval 'push @'.$class."::ISA, 'Lufs::Glue'"; | ||
| 28 | $self->{fs} = bless {} => $class; | ||
| 29 | $opt->{logfile} ||= '/tmp/perlfs.log'; | ||
| 30 | open(STDERR, ">> $opt->{logfile}") if $opt->{logfile}; | ||
| 31 | $Lufs::Glue::trace = 1 if $opt->{logfile}; | ||
| 32 | $self->{fs}->init($opt); | ||
| 33 | } | ||
| 34 | |||
| 35 | sub AUTOLOAD { | ||
| 36 | my $self = shift; | ||
| 37 | my $method = (split/::/,$AUTOLOAD)[-1]; | ||
| 38 | $method eq 'DESTROY' && return; | ||
| 39 | if ($self->{fs}->can($method)) { | ||
| 40 | return $self->{fs}->$method(@_); | ||
| 41 | } | ||
| 42 | else { | ||
| 43 | print STDERR "$method not implemented\n"; | ||
| 44 | } | ||
| 45 | return 0; | ||
| 46 | } | ||
| 47 | |||
| 48 | 1; | ||
| 49 | __END__ |