mllib: introduce Mkdtemp.temp_dir

Add a simple function to ease the usage of Mkdtemp.mkdtemp.
This commit is contained in:
Pino Toscano
2014-07-07 19:30:29 +02:00
parent 3fc6983b16
commit c8f3e99302
2 changed files with 12 additions and 0 deletions

View File

@@ -16,4 +16,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
open Common_utils
external mkdtemp : string -> string = "virt_builder_mkdtemp"
let temp_dir ?(base_dir = Filename.temp_dir_name) prefix suffix =
mkdtemp (base_dir // (prefix ^ "XXXXXX" ^ suffix))

View File

@@ -18,3 +18,10 @@
val mkdtemp : string -> string
(** [mkdtemp pattern] Tiny wrapper to the C [mkdtemp]. *)
val temp_dir : ?base_dir:string -> string -> string -> string
(** [temp_dir prefix suffix] creates a new unique temporary directory.
The optional [~base_dir:string] changes the base directory where
to create the new temporary directory; if not specified, the default
[Filename.temp_dir_name] is used. *)