Files
paparazzi/sw/lib/ocaml/http.ml
T
2006-03-03 16:36:23 +00:00

19 lines
458 B
OCaml

exception Failure of string
let file_of_url = fun ?dest url ->
if String.sub url 0 7 = "file://" then
String.sub url 7 (String.length url - 7)
else
let tmp_file =
match dest with
Some s -> s
| None -> Filename.temp_file "fp" ".wget" in
let c = Printf.sprintf "wget --cache=off -O %s '%s'" tmp_file url in
if Sys.command c = 0 then
tmp_file
else begin
Sys.remove tmp_file;
raise (Failure url)
end