summaryrefslogtreecommitdiffstats
path: root/ocaml
diff options
context:
space:
mode:
Diffstat (limited to 'ocaml')
-rw-r--r--ocaml/guestfs.ml1
-rw-r--r--ocaml/guestfs.mli3
-rw-r--r--ocaml/guestfs_c_actions.c24
3 files changed, 28 insertions, 0 deletions
diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml
index f0c789ba..a48b5264 100644
--- a/ocaml/guestfs.ml
+++ b/ocaml/guestfs.ml
@@ -283,3 +283,4 @@ external glob_expand : t -> string -> string array = "ocaml_guestfs_glob_expand"
external scrub_device : t -> string -> unit = "ocaml_guestfs_scrub_device"
external scrub_file : t -> string -> unit = "ocaml_guestfs_scrub_file"
external scrub_freespace : t -> string -> unit = "ocaml_guestfs_scrub_freespace"
+external mkdtemp : t -> string -> string = "ocaml_guestfs_mkdtemp"
diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli
index d93cfdc8..d26d5bb0 100644
--- a/ocaml/guestfs.mli
+++ b/ocaml/guestfs.mli
@@ -628,3 +628,6 @@ val scrub_file : t -> string -> unit
val scrub_freespace : t -> string -> unit
(** scrub (securely wipe) free space *)
+val mkdtemp : t -> string -> string
+(** create a temporary directory *)
+
diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c
index a8204e8a..f4079564 100644
--- a/ocaml/guestfs_c_actions.c
+++ b/ocaml/guestfs_c_actions.c
@@ -4343,3 +4343,27 @@ ocaml_guestfs_scrub_freespace (value gv, value dirv)
CAMLreturn (rv);
}
+CAMLprim value
+ocaml_guestfs_mkdtemp (value gv, value templatev)
+{
+ CAMLparam2 (gv, templatev);
+ CAMLlocal1 (rv);
+
+ guestfs_h *g = Guestfs_val (gv);
+ if (g == NULL)
+ caml_failwith ("mkdtemp: used handle after closing it");
+
+ const char *template = String_val (templatev);
+ char *r;
+
+ caml_enter_blocking_section ();
+ r = guestfs_mkdtemp (g, template);
+ caml_leave_blocking_section ();
+ if (r == NULL)
+ ocaml_guestfs_raise_error (g, "mkdtemp");
+
+ rv = caml_copy_string (r);
+ free (r);
+ CAMLreturn (rv);
+}
+