X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Finterface%2Fhttp_getter%2Fhttp_getter.pl;fp=helm%2Finterface%2Fhttp_getter%2Fhttp_getter.pl;h=cfe9a79ad736e79fb6b770d32c998a25cadebf2f;hb=8bc2bd57ad4d9ea0fdd753e56616fd8f74cb78a2;hp=650a16a3b2a0179156317247e64bfda13c477bee;hpb=517ec5ef7e873c8c75fa5f21f4b54e423fc21955;p=helm.git 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); +}