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.3 by williamc, Wed Aug 25 08:41:40 1999 UTC vs.
Revision 1.4 by williamc, Wed Aug 25 15:43:18 1999 UTC

# Line 6 | Line 6
6   # new(cachedir)       : A new urlhandler with a defined default cahce directory
7   # get(url)            : download from the specified url to the default cache
8   # get(url,dirlocation)   : download to the specified directory
9 < # setbase(type,@args) : set the url defaults for a specific url type
10 < #                       arguments are dependent on type
11 < #                       http:
12 < #                       file:
13 < #                       cvs: servername,servertype [ ,user,passkey ]
14 < #                       label:
9 > # setbase(type,variablehash) : set the url defaults for a specific url type
10 > #                              arguments are dependent on type
11   # unsetbase(type)  : deactivate a previously set base
12 + # setcache(dir)    : set the default cache location
13   #
14   # ----------------------------------------------------------------------
15   # returns file location - or crashes out
# Line 51 | Line 48 | sub init {
48          $self->setbase("file", {}); # Base file as default
49   }
50  
51 + sub setcache {
52 +        my $self=shift;
53 +        my $cache=shift;
54 +
55 +        $self->{cache}=$cache;
56 + }
57 +
58   sub get ($@) {
59          my $self=shift;
60          my $origurl=shift;
# Line 59 | Line 63 | sub get ($@) {
63          my $type;
64          my $url;
65          my $version;
66 +        my $rv="";
67  
68          if ( ! defined $dirname ) {
69            $dirname=$self->{cache};
70          }
71 +        print "dirname = $dirname \n";
72          chdir $dirname or carp "Unable to Enter Directory $dirname $!\n";
73          chomp $origurl;
74          # get our version info from the url (after last ??)
# Line 79 | Line 85 | sub get ($@) {
85             carp;
86          }
87          else {
82           print "Debug : type=$type , number of elements=".$#{$self->{urlostack}{$type}}." ".${$self->{urlostack}{$type}}[$#{$self->{urlostack}{$type}}]."\n";
88             if ( $#{$self->{urlostack}{$type}} < 0 ) {
89                  print "URLhandler : base not set for type $type \n";
90             }
91             else {
92 +             $rv=
93               eval{${$self->{urlostack}{$type}}[$#{$self->{urlostack}{$type}}]}->
94                                  get($rest);
95             }
96          }
97 +        if ( $rv ne "" ) {
98 +                $rv=$dirname."/".$rv;
99 +        }
100 +        return $rv;
101   }
102  
103   sub setbase {
# Line 105 | Line 115 | sub setbase {
115            # A new URL object - pushed onto the stack
116            $oref=eval{$self->{urlmodules}{$type}}->new();
117            push @{$self->{urlostack}{$type}}, $oref;
108        print "Debug : Setting type=$type to $oref $#{$self->{urlostack}{$type}}\n";
118            $oref->setbase(@args);
119          }
120   }
# Line 115 | Line 124 | sub unsetbase {
124          my $type=shift;
125          my $oref;
126  
118        print " Debug : Unsetting base type $type\n";
127          # Check type is supported
128          if ( ! exists $self->{urlmodules}{$type} ) {
129            print "URLhandler error: Unsupported type $type\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines