]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/getter/http_getter_misc.ml
ocaml 3.09 transition
[helm.git] / helm / ocaml / getter / http_getter_misc.ml
index 0430c1b48d3cf96856499f9e3fe418c801cc022a..b7b52bbf64309da80028b1b5cfd47fff7c31c615 100644 (file)
@@ -294,3 +294,20 @@ let extension s =
     String.sub s idx (String.length s - idx)
   with Not_found -> ""
 
+let temp_file_of_uri uri =
+  let flat_string s s' c =
+    let cs = String.copy s in
+    for i = 0 to (String.length s) - 1 do
+      if String.contains s' s.[i] then cs.[i] <- c
+    done;
+    cs
+  in
+  let user = try Unix.getlogin () with _ -> "" in
+  Filename.open_temp_file (user ^ flat_string uri ".-=:;!?/&" '_') ""
+
+let backtick cmd =
+  let ic = Unix.open_process_in cmd in
+  let res = input_line ic in
+  ignore (Unix.close_process_in ic);
+  res
+