mruby-dir: add compatibility macro
@@ -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);
