[Pkg-libvirt-commits] [libguestfs] 79/156: mllib: introduce Mkdtemp.temp_dir

Hilko Bengen bengen at moszumanska.debian.org
Sat Aug 30 08:26:00 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch master
in repository libguestfs.

commit 6bd5b24561da0d3c4a74ee1313eae2c24027ed78
Author: Pino Toscano <ptoscano at redhat.com>
Date:   Mon Jul 7 19:30:29 2014 +0200

    mllib: introduce Mkdtemp.temp_dir
    
    Add a simple function to ease the usage of Mkdtemp.mkdtemp.
    
    (cherry picked from commit c8f3e99302e65a0c10bc82df49789d159bf17e5c)
---
 mllib/mkdtemp.ml  | 5 +++++
 mllib/mkdtemp.mli | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/mllib/mkdtemp.ml b/mllib/mkdtemp.ml
index 2e64862..353b04b 100644
--- a/mllib/mkdtemp.ml
+++ b/mllib/mkdtemp.ml
@@ -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))
diff --git a/mllib/mkdtemp.mli b/mllib/mkdtemp.mli
index 674e6f2..9abb10c 100644
--- a/mllib/mkdtemp.mli
+++ b/mllib/mkdtemp.mli
@@ -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. *)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list