ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/URLhandler.pm
(Generate patch)

Comparing COMP/SCRAM/src/URL/URLhandler.pm (file contents):
Revision 1.13 by williamc, Wed Mar 29 09:48:33 2000 UTC vs.
Revision 1.15.2.5 by williamc, Thu Aug 10 13:25:33 2000 UTC

# Line 1 | Line 1
1 # url handler -> returns the location of the file
1   # Interface
2   # ---------
3   # new(cache)       : A new urlhandler with a defined default cahce directory
# Line 6 | Line 5
5   # get(url,[location]) : download from the specified url to cache or location
6   #                       return the full url path name incl. any base expansion
7   #                       and the filename downloaded to
8 < # setbase(type,variablehash) : set the url defaults for a specific url type
10 < #                              arguments are dependent on type
8 > # setbase(urlstring) : set a base url type - return the url object
9   # unsetbase(type)  : deactivate a previously set base
10   # currentbase(type) : return the current base for the given type
11 + # expandurl(urlstring) : return the base expanded URLclass of the given string
12   #
13   # ----------------------------------------------------------------------
14  
# Line 18 | Line 17 | require 5.004;
17   use Utilities::AddDir;
18   use URL::URLcache;
19   use URL::URLclass;
21 use URL::URLbase;
20   use Carp;
21  
22   sub new {
# Line 35 | Line 33 | sub init {
33          my $self=shift;
34          my $cache=shift;
35          $self->{cache}=$cache;
38        $self->{dummybase}=URL::URLbase->new({});
36          $self->{cachestore}=$self->{cache}->filestore();
37          use URL::URL_cvs;
41        use URL::URL_cvsfile;
38          use URL::URL_file;
39          use URL::URL_test;
44        use URL::URL_filed;
40          $self->{urlmodules}={
46                        'cvsfile' => 'URL::URL_cvsfile',
41                          'cvs' => 'URL::URL_cvs',
42                          'file' => 'URL::URL_file',
49                        'filed' => 'URL::URL_filed',
43                          'test' => 'URL::URL_test'
44                  };
45   }
# Line 58 | Line 51 | sub get {
51  
52          my $url=URL::URLclass->new($origurl);
53          my $type=$url->type();
54 <        $url->expandurl($self->currentbase($type));
54 >        $url->merge($self->currentbase($type));
55          my $fullurl=$url->url();
56  
57          $file=$self->{cache}->file($fullurl);
# Line 76 | Line 69 | sub download {
69          my $url=URL::URLclass->new($origurl);
70          my $type=$url->type();
71          $urltypehandler=$self->_typehandler($type);
72 <        $url->expandurl($self->currentbase($type));
72 >        $url->merge($self->currentbase($type));
73 >        print "Attempting download of ".$url->url()."\n";
74  
75          # Generate a location name if not provided
76 <        $nocache=1;
76 >        my $nocache=1;
77          if ( @_ ) {
78             $location=shift;
79             $nocache=0; # dont cache if downloaded to an external location
# Line 95 | Line 89 | sub download {
89  
90          # now register it in the cache if successful
91          if ( $file && $nocache) {
92 <          $self->{cache}->store($url->url(), $location);
92 >          #$self->{cache}->store($url->url(), $location);
93 >          $self->{cache}->store($url->url(), $file);
94          }
95          return ($url->url(), $file);
96   }
97  
98 + sub expandurl {
99 +        my $self=shift;
100 +        my $urlstring=shift;
101 +
102 +        my $url=URL::URLclass->new($urlstring);
103 +        my $type=$url->type();
104 +        $url->merge($self->currentbase($type));
105 +        return $url;
106 + }
107 +
108   sub setbase {
109          my $self=shift;
110 <        my $type=shift;
106 <        my @args=@_;
107 <        my $oref;
110 >        my $partialurl=shift;
111  
112 +        my $base=URL::URLclass->new($partialurl);
113 +        my $type=$base->type();
114          $self->checktype($type);
115 <        # make a new base object
111 <        my $base=URL::URLbase->new(@_);
115 >        # make a new base-url object
116          push @{$self->{"basestack"}{$type}}, $base;
117 +        return $base;
118   }
119  
120   sub unsetbase {
# Line 141 | Line 146 | sub currentbase {
146            $rv=${$self->{basestack}{$type}}[$#{$self->{basestack}{$type}}];
147          }
148          else {
149 <          $rv=$self->{dummybase};
149 >          $rv=undef;
150          }
151          return $rv;
152   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines