mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-06 16:58:48 +08:00
19 lines
458 B
OCaml
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
|