Merge pull request #3895 from mattn/fix-mkstemp

fix mkstemp implementation for MSVC
This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-12-14 00:46:19 +09:00
committed by GitHub
+11 -2
View File
@@ -19,8 +19,14 @@ typedef int mode_t;
static int
mkstemp(char *p)
{
_mktemp(p);
return 0;
int fd;
char* fname = _mktemp(p);
if (fname == NULL)
return -1;
fd = open(fname, O_RDWR | O_CREAT | O_EXCL, _S_IREAD | _S_IWRITE);
if (fd >= 0)
return fd;
return -1;
}
#endif
@@ -75,6 +81,9 @@ mrb_io_test_io_setup(mrb_state *mrb, mrb_value self)
mrb_raise(mrb, E_RUNTIME_ERROR, "can't create temporary file");
return mrb_nil_value();
}
close(fd0);
close(fd1);
#if !defined(_WIN32) && !defined(_WIN64)
fd2 = mkstemp(symlinkname);
fd3 = mkstemp(socketname);