From 8bc2bd57ad4d9ea0fdd753e56616fd8f74cb78a2 Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Wed, 15 Nov 2000 17:14:57 +0000 Subject: [PATCH] Other patches to this file. It must be rewritten from scratch sooner or later. --- helm/interface/http_getter/http_getter.pl | 31 +++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/helm/interface/http_getter/http_getter.pl b/helm/interface/http_getter/http_getter.pl index 650a16a3b..cfe9a79ad 100755 --- a/helm/interface/http_getter/http_getter.pl +++ b/helm/interface/http_getter/http_getter.pl @@ -55,7 +55,8 @@ while (my $c = $d->accept) { $response = $ua->request($request, \&callback); print "Storing file\n"; - open(FD, $filename); + mkdirs($filename); + open(FD, ">".$filename); print FD $cont; close(FD); @@ -95,7 +96,8 @@ while (my $c = $d->accept) { $response = $ua->request($request, \&callback); print "Storing file for the annotation\n"; - open(FD, $filename); + mkdirs($filename); + open(FD, ">".$filename); print FD $cont; close(FD); } @@ -117,7 +119,8 @@ while (my $c = $d->accept) { $response = $ua->request($request, \&callback); print "Storing file for the file to annotate\n"; - open(FD, $filename_target); + mkdirs($filename_target); + open(FD, ">".$filename_target); print FD $cont; close(FD); } @@ -176,7 +179,8 @@ EOT $response = $ua->request($request, \&callback); print "Storing file for the types\n"; - open(FD, $filename); + mkdirs($filename); + open(FD, ">".$filename); print FD $cont; close(FD); } @@ -199,7 +203,8 @@ EOT $response = $ua->request($request, \&callback); print "Storing file for the file to type\n"; - open(FD, $filename_target); + mkdirs($filename_target); + open(FD, ">".$filename_target); print FD $cont; close(FD); } @@ -276,3 +281,19 @@ sub callback my ($data) = @_; $cont .= $data; } + +# Does not raise errors if could not create dirs/files + +# Too much powerful: creates even /home, /home/users/, ... +sub mkdirs +{ + my ($pathname) = @_; + my @dirs = split /\//,$pathname; + my $tmp; + foreach $dir (@dirs) { + $tmp = ((defined($tmp)) ? $tmp = $tmp."\/".$dir : ""); + print $tmp."\n"; + mkdir($tmp,0777); + } + rmdir($tmp); +} -- 2.39.2