From 9df7bceb156d9eb5262fc742fa83f025f64b9d09 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 8 Dec 2017 09:19:59 +0900 Subject: AppVeyor compiler does not proved some POSIX functions. - `mode_t` by `int` - `umask` by `_umask` - `rmdir` by `_rmdir` - `mkstemp` and `mkdtemp` by using `_mktemp` --- mrbgems/mruby-io/test/mruby_io_test.c | 42 +++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/mrbgems/mruby-io/test/mruby_io_test.c b/mrbgems/mruby-io/test/mruby_io_test.c index ffaa27ff4..35dce463e 100644 --- a/mrbgems/mruby-io/test/mruby_io_test.c +++ b/mrbgems/mruby-io/test/mruby_io_test.c @@ -2,8 +2,46 @@ #include #if defined(_WIN32) || defined(_WIN64) - #include - #include + +#include +#include +#include +#include +#include +#include + +typedef int mode_t; + +static int +mkstemp(char *p) +{ + char *template, *path; + char *path; + int fd; + + template = strdup(p); + if (template == NULL) return -1; + path = _mktemp(template); + if (path[0] == 0) { + free(path); + return -1; + } + fd = _open(path, _O_CREAT|_O_BINARY|_O_RDWR|_O_TEMPORARY); + free(path); + return fd; +} + +static char* +mkdtemp(char *template) +{ + char *path = _mktemp(template); + if (path[0] == 0) return NULL; + if (_mkdir(path) < 0) return NULL; + return path; +} + +#define umask(mode) _umask(mode) +#define rmdir(path) _rmdir(path) #else #include #include -- cgit v1.2.3