mruby-dir: add compatibility macro

This commit is contained in:
Yukihiro "Matz" Matsumoto
2022-12-21 15:15:10 +09:00
parent b93a624b5f
commit d656ea87c6
+7 -5
View File
@@ -146,6 +146,12 @@ mrb_dir_getwd(mrb_state *mrb, mrb_value klass)
return path;
}
#ifndef _WIN32
#define MAKE_DIR(path, mode) mkdir(path, mode)
#else
#define MAKE_DIR(path, mode) mkdir(path)
#endif
mrb_value
mrb_dir_mkdir(mrb_state *mrb, mrb_value klass)
{
@@ -156,11 +162,7 @@ mrb_dir_mkdir(mrb_state *mrb, mrb_value klass)
mode = 0777;
mrb_get_args(mrb, "S|i", &spath, &mode);
path = mrb_str_to_cstr(mrb, spath);
#ifndef _WIN32
if (mkdir(path, mode) == -1) {
#else
if (mkdir(path) == -1) {
#endif
if (MAKE_DIR(path, mode) == -1) {
mrb_sys_fail(mrb, path);
}
return mrb_fixnum_value(0);