1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
(* This file is part of Lwt, released under the MIT license. See LICENSE.md for
details, or visit https://github.com/ocsigen/lwt/blob/master/LICENSE.md. *)
let temp_name =
let rng = Random.State.make_self_init () in
fun () ->
let number = Random.State.int rng 10000 in
Printf.sprintf "lwt-testing-%04d" number
let temp_file () =
Filename.temp_file ~temp_dir:"." "lwt-testing-" ""
let temp_directory () =
let rec attempt () =
let path = temp_name () in
try
Unix.mkdir path 0o755;
path
with Unix.Unix_error (Unix.EEXIST, "mkdir", _) -> attempt ()
in
attempt ()
|