summaryrefslogtreecommitdiffhomepage
path: root/mrbgems
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-12-14 00:46:19 +0900
committerGitHub <[email protected]>2017-12-14 00:46:19 +0900
commitebf49932c7b3cda14cd00a7bcf562fc85138c02c (patch)
tree1efb03ef698e822b9f34609ff3da0ca5332c1d43 /mrbgems
parentf0379c8c45887773aacf689a73fb799f88c2d42c (diff)
parente7e5db51de46cf6710e7019ac4931614ccdd448f (diff)
downloadmruby-ebf49932c7b3cda14cd00a7bcf562fc85138c02c.tar.gz
mruby-ebf49932c7b3cda14cd00a7bcf562fc85138c02c.zip
Merge pull request #3895 from mattn/fix-mkstemp
fix mkstemp implementation for MSVC
Diffstat (limited to 'mrbgems')
-rw-r--r--mrbgems/mruby-io/test/mruby_io_test.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/mrbgems/mruby-io/test/mruby_io_test.c b/mrbgems/mruby-io/test/mruby_io_test.c
index 7e25dddc2..c0bbb91ac 100644
--- a/mrbgems/mruby-io/test/mruby_io_test.c
+++ b/mrbgems/mruby-io/test/mruby_io_test.c
@@ -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);