ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/URL_file.pm
Revision: 1.2
Committed: Wed Aug 25 08:41:40 1999 UTC (25 years, 8 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.1: +5 -1 lines
Log Message:
Update all for get interface

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