mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #94 from kazuho/kazuho/rename-compatibility
make `rename` behavior consistent with MRI
This commit is contained in:
@@ -119,9 +119,11 @@ mrb_file_s_rename(mrb_state *mrb, mrb_value obj)
|
||||
src = mrb_string_value_cstr(mrb, &from);
|
||||
dst = mrb_string_value_cstr(mrb, &to);
|
||||
if (rename(src, dst) < 0) {
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
if (CHMOD(dst, 0666) == 0 && UNLINK(dst) == 0 && rename(src, dst) == 0) {
|
||||
return mrb_fixnum_value(0);
|
||||
}
|
||||
#endif
|
||||
mrb_sys_fail(mrb, mrb_str_to_cstr(mrb, mrb_format(mrb, "(%S, %S)", from, to)));
|
||||
}
|
||||
return mrb_fixnum_value(0);
|
||||
|
||||
Reference in New Issue
Block a user