ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/URL_file.pm
Revision: 1.1
Committed: Mon Aug 23 15:53:53 1999 UTC (25 years, 8 months ago) by williamc
Content type: text/plain
Branch: MAIN
Log Message:
Basic Functionality tested via URLhandler

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     package URL_file;
12     require 5.001;
13     use File::Copy;
14    
15     sub new {
16     my $class=shift;
17     $self={};
18     bless $self, $class;
19     $self->{path}="";
20     return $self;
21     }
22    
23     sub setbase {
24     my $self=shift;
25     my $varhash=shift;
26    
27     if ( exists $$varhash{'base'} ) {
28     $self->{path}=$$varhash{'base'};
29     }
30     }
31    
32     sub unsetbase {
33     my $self=shift;
34     $self->{path}="";
35     }
36    
37     sub get {
38     my $self=shift;
39     my $file=shift;
40     my $filename=shift;
41    
42     my $urlfile;
43    
44     $urlfile=$self->{path}."/".$file;
45     if ( -e "$urlfile" ) {
46     copy ( $urlfile, $filename ) || die "Unable to copy file $urlfile --> "
47     ."$filename $!";
48     return $filename;
49     }
50     else {
51     print "URL_file : Unable to find file $urlfile : $!\n";
52     return "";
53     }
54     }