]> matita.cs.unibo.it Git - helm.git/commitdiff
Other patches to this file. It must be rewritten from scratch
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Wed, 15 Nov 2000 17:14:57 +0000 (17:14 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Wed, 15 Nov 2000 17:14:57 +0000 (17:14 +0000)
sooner or later.

helm/interface/http_getter/http_getter.pl

index 650a16a3b2a0179156317247e64bfda13c477bee..cfe9a79ad736e79fb6b770d32c998a25cadebf2f 100755 (executable)
@@ -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);
+}