1 |
#
|
2 |
# standard url interface for local file - direct use no copying to cache
|
3 |
#
|
4 |
# Interface
|
5 |
# ---------
|
6 |
# new() :
|
7 |
# setbase() :
|
8 |
# unsetbase() :
|
9 |
# get(url, destination) :
|
10 |
|
11 |
package URL::URL_filed;
|
12 |
require 5.001;
|
13 |
use File::Copy;
|
14 |
use URL::URL_base;
|
15 |
@ISA=qw(URL::URL_base);
|
16 |
|
17 |
sub new {
|
18 |
my $class=shift;
|
19 |
$self={};
|
20 |
bless $self, $class;
|
21 |
$self->{path}="";
|
22 |
return $self;
|
23 |
}
|
24 |
|
25 |
sub setbase {
|
26 |
my $self=shift;
|
27 |
my $varhash=shift;
|
28 |
|
29 |
if ( exists $$varhash{'base'} ) {
|
30 |
$self->{path}=$$varhash{'base'};
|
31 |
}
|
32 |
}
|
33 |
|
34 |
sub unsetbase {
|
35 |
my $self=shift;
|
36 |
$self->{path}="";
|
37 |
}
|
38 |
|
39 |
sub get {
|
40 |
my $self=shift;
|
41 |
my $file=shift;
|
42 |
my $dir=shift; # Were not copying anything so this is irrelevant
|
43 |
|
44 |
my $rv="";
|
45 |
my $urlfile=$file;
|
46 |
|
47 |
if ( $file!~/^\// ) {
|
48 |
$urlfile=$self->{path}."/".$file;
|
49 |
}
|
50 |
if ( -e "$urlfile" ) {
|
51 |
$rv=$urlfile;
|
52 |
}
|
53 |
return $rv;
|
54 |
}
|