ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/URL_file.pm
Revision: 1.4
Committed: Wed Sep 29 07:29:02 1999 UTC (25 years, 7 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.3: +3 -2 lines
Log Message:
URL:: mods

File Contents

# User Rev Content
1 williamc 1.1 #
2     # standard url interface for local file
3     #
4     # Interface
5     # ---------
6     # new() :
7     # setbase() :
8     # unsetbase() :
9     # get(url, destination) :
10    
11 williamc 1.4 package URL::URL_file;
12 williamc 1.1 require 5.001;
13     use File::Copy;
14 williamc 1.4 use URL::URL_base;
15     @ISA=qw(URL::URL_base);
16 williamc 1.1
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 williamc 1.2
43     my $filename;
44    
45     $filename=$self->getfilefrompath($file);
46 williamc 1.1
47     my $urlfile;
48    
49     $urlfile=$self->{path}."/".$file;
50     if ( -e "$urlfile" ) {
51     copy ( $urlfile, $filename ) || die "Unable to copy file $urlfile --> "
52     ."$filename $!";
53 williamc 1.3 $rv=$filename;
54 williamc 1.1 }
55     else {
56     print "URL_file : Unable to find file $urlfile : $!\n";
57 williamc 1.3 $rv="";
58 williamc 1.1 }
59 williamc 1.3 return $rv;
60 williamc 1.1 }