1 |
– |
#!/usr/local/bin/perl5 |
2 |
– |
# |
1 |
|
# url handler -> returns the location of the file |
2 |
|
# |
3 |
|
# returns file location - or crashes out |
5 |
|
# if not then stores in a default cache. |
6 |
|
|
7 |
|
package urlhandler; |
8 |
+ |
require 5.004; |
9 |
|
require Exporter; |
10 |
|
@ISA = qw(Exporter); |
11 |
|
@EXPORT = qw(urlhandler); |
30 |
|
$rest=$url.":".$version; |
31 |
|
} |
32 |
|
|
33 |
< |
my @urltypes = qw(label file cvs); |
33 |
> |
my @urltypes = qw(label file cvs http); |
34 |
|
foreach $ty ( @urltypes ) { |
35 |
|
do { return &$ty($rest, $filename); $supported='yes'; last; } |
36 |
|
if $type eq $ty; |
54 |
|
} |
55 |
|
} |
56 |
|
close LOOKUP; |
57 |
< |
return $returnval; |
58 |
< |
|
57 |
> |
if ( $returnval ne "" ) { |
58 |
> |
return $returnval; |
59 |
> |
} |
60 |
> |
($proj,$ver)=split /:/, $label; |
61 |
> |
print "Error : Unknown project name or version (".$proj." ".$ver.")\n"; |
62 |
> |
exit 1; |
63 |
|
} |
64 |
|
|
65 |
|
sub file { |
83 |
|
print "Coming soon\n"; |
84 |
|
} |
85 |
|
|
86 |
+ |
sub http { |
87 |
+ |
my $urlfile=shift; |
88 |
+ |
my $filename=shift; |
89 |
+ |
use LWP::Simple; |
90 |
+ |
print "Hello $filename, $urlfile\n"; |
91 |
+ |
open (STORE, ">$filename") || die "unable to open file $filename $!\n"; |
92 |
+ |
print STORE (get 'http:'.$urlfile); |
93 |
+ |
close STORE; |
94 |
+ |
} |
95 |
+ |
|
96 |
|
sub cachefilename { |
97 |
|
use File::Basename; |
98 |
< |
use AddDir; |
98 |
> |
use Utilities::AddDir; |
99 |
|
my $filebase=dirname($rest); |
100 |
|
$cache="/tmp/williamc/urlhandler$$"; |
101 |
|
adddir($cache); |