]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/interface/http_getter/http_getter.pl
Some debug print removed
[helm.git] / helm / interface / http_getter / http_getter.pl
index 9ea1641b7c7b2036ca3b71216267f3fa1a448b23..ce25c093f495744ca78fe4b21e05e1e24d8e922e 100755 (executable)
@@ -4,7 +4,7 @@
 use Env;
 my $HELM_CONFIGURATION_PREFIX = $ENV{"HELM_CONFIGURATION_PREFIX"};
 my $HELM_CONFIGURATION_PATH =
- $HELM_CONFIGURATION_PREFIX."local/lib/helm/configuration.pl";
+ $HELM_CONFIGURATION_PREFIX."/local/lib/helm/configuration.pl";
 # next require defines: $helm_dir, $html_link
 require $HELM_CONFIGURATION_PATH;
 
@@ -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,18 @@ 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 : "");
+  mkdir($tmp,0777);
+ }
+ rmdir($tmp);
+}