Navigation Menu

Skip to content

Commit

Permalink
windows: fix mkstemp() implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 16, 2015
1 parent 4de4d06 commit 0d25626
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/util.c
Expand Up @@ -25,9 +25,12 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/stat.h>

#ifdef WIN32
# include <io.h>
# include <share.h>
#endif /* WIN32 */

grn_rc
Expand Down Expand Up @@ -1350,16 +1353,20 @@ int
grn_mkstemp(char *path_template)
{
errno_t error;
int fd;
size_t path_template_size;
int fd;

path_template_size = strlen(path_template) + 1;
error = _mktemp_s(path_template, path_template_size);
if (error != 0) {
return -1;
}

error = fopen_s(&fd, path_template, "wb");
error = _sopen_s(&fd,
path_template,
_O_RDWR | _O_CREAT | _O_EXCL | _O_BINARY,
_SH_DENYNO,
_S_IREAD | _S_IWRITE);
if (error != 0) {
return -1;
}
Expand Down

0 comments on commit 0d25626

Please sign in to comment.