Index: /trunk/include/iprt/dir.h
===================================================================
--- /trunk/include/iprt/dir.h	(revision 20065)
+++ /trunk/include/iprt/dir.h	(revision 20066)
@@ -62,6 +62,5 @@
  * @param   pszPath   Path to the directory to create.
  * @param   fMode      The mode of the new directory.
- */
-RTDECL(int) RTDirCreate(const char *pszPath, RTFMODE fMode);
+ */ RTDECL(int) RTDirCreate(const char *pszPath, RTFMODE fMode);
 
 /**
@@ -74,4 +73,17 @@
  */
 RTDECL(int) RTDirCreateFullPath(const char *pszPath, RTFMODE fMode);
+
+/**
+ * Creates a directory with a temporary name which is guaranteed not 
+ * to exists. It takes a path with a directory name template and 
+ * overwrites a portion of it to create the unique name. The template 
+ * may be any directory name with some numbers of `Xs` appended to it. 
+ * The trailing `Xs` are replaced with the unique numbers. The 
+ * directory is created with mode 0700.
+ *
+ * @returns iprt status code.
+ * @param   pszTemplate     Buffer with the template path.
+ */
+RTDECL(int) RTDirCreateTemp(char *pszTemplate);
 
 /**
Index: /trunk/src/VBox/Runtime/r3/posix/dir-posix.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/posix/dir-posix.cpp	(revision 20065)
+++ /trunk/src/VBox/Runtime/r3/posix/dir-posix.cpp	(revision 20066)
@@ -107,4 +107,12 @@
     LogFlow(("RTDirCreate(%p={%s}, %RTfmode): returns %Rrc\n", pszPath, pszPath, fMode, rc));
     return rc;
+}
+
+RTDECL(int) RTDirCreateTemp(char *pszTemplate)
+{
+    if (mkdtemp(pszTemplate))
+        return VINF_SUCCESS;
+    
+    return RTErrConvertFromErrno(errno);
 }
 
Index: /trunk/src/VBox/Runtime/r3/win/dir-win.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/win/dir-win.cpp	(revision 20065)
+++ /trunk/src/VBox/Runtime/r3/win/dir-win.cpp	(revision 20066)
@@ -35,4 +35,5 @@
 #define LOG_GROUP RTLOGGROUP_DIR
 #include <Windows.h>
+#include <io.h>
 
 #include <iprt/dir.h>
@@ -128,4 +129,15 @@
 
 
+RTDECL(int) RTDirCreateTemp(char *pszTemplate)
+{
+    if (!_mktemp(pszTemplate))
+    {
+        int rc = RTDirCreate(pszTemplate, 0700);
+        return rc;
+    }
+    return RTErrConvertFromWin32(GetLastError());
+}
+
+
 RTDECL(int) RTDirRemove(const char *pszPath)
 {
