update for HEAD-2003021201
[reactos.git] / lib / msvcrt / stdio / wtempnam.c
diff --git a/lib/msvcrt/stdio/wtempnam.c b/lib/msvcrt/stdio/wtempnam.c
new file mode 100644 (file)
index 0000000..c35118b
--- /dev/null
@@ -0,0 +1,22 @@
+#include <windows.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/stdlib.h>
+
+
+wchar_t* _wtempnam(const wchar_t* dir, const wchar_t* prefix)
+{
+    wchar_t* TempFileName = malloc(MAX_PATH);
+    wchar_t* d;
+
+    if (dir == NULL)
+        d = _wgetenv(L"TMP");
+    else
+        d = (wchar_t*)dir;
+
+    if (GetTempFileNameW(d, prefix, 1, TempFileName) == 0) {
+        free(TempFileName);
+        return NULL;
+    }
+
+    return TempFileName;
+}