From b10144e5b4403409b4248c345144989fa5b61670 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 21 Mar 2010 21:44:57 +0100 Subject: [PATCH] Working implementation of mkstemp on Windows. --- src/osdep/win32/win32.c | 5 ++--- src/util/secsave.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/osdep/win32/win32.c b/src/osdep/win32/win32.c index 66b212888..134b8c8bb 100644 --- a/src/osdep/win32/win32.c +++ b/src/osdep/win32/win32.c @@ -226,16 +226,15 @@ gettimeofday(struct timeval* p, void* tz) int mkstemp(char *template) { - char tempname[MAX_PATH]; char pathname[MAX_PATH]; /* Get the directory for temp files */ GetTempPath(MAX_PATH, pathname); /* Create a temporary file. */ - GetTempFileName(pathname, template, 0, tempname); + GetTempFileName(pathname, "ABC", 0, template); - return open(tempname, O_CREAT | O_WRONLY | O_EXCL | O_BINARY); + return open(template, O_WRONLY | O_BINARY | O_EXCL); } int diff --git a/src/util/secsave.c b/src/util/secsave.c index f7b18395f..10bd2ee04 100644 --- a/src/util/secsave.c +++ b/src/util/secsave.c @@ -274,7 +274,7 @@ secure_close(struct secure_save_info *ssi) } if (ssi->secure_save && ssi->file_name && ssi->tmp_file_name) { -#ifdef CONFIG_OS_OS2 +#if defined(CONFIG_OS_OS2) || defined(CONFIG_OS_WIN32) /* OS/2 needs this, however it breaks atomicity on * UN*X. */ unlink(ssi->file_name);