diff options
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -4400,6 +4400,21 @@ rb_check_realpath_emulate(VALUE basedir, VALUE path, rb_encoding *origenc, enum static VALUE rb_file_join(VALUE ary); +#ifndef HAVE_REALPATH +static VALUE +rb_check_realpath_emulate_try(VALUE arg) +{ + VALUE *args = (VALUE *)arg; + return rb_check_realpath_emulate(args[0], args[1], (const rb_encoding *)args[2], RB_REALPATH_CHECK); +} + +static VALUE +rb_check_realpath_emulate_rescue(VALUE arg, VALUE exc) +{ + return Qnil; +} +#endif /* HAVE_REALPATH */ + static VALUE rb_check_realpath_internal(VALUE basedir, VALUE path, rb_encoding *origenc, enum rb_realpath_mode mode) { @@ -4466,7 +4481,18 @@ rb_check_realpath_internal(VALUE basedir, VALUE path, rb_encoding *origenc, enum RB_GC_GUARD(unresolved_path); return resolved; #else - return rb_check_realpath_emulate(basedir, path, origenc, mode); + if (mode == RB_REALPATH_CHECK) { + VALUE arg[3]; + arg[0] = basedir; + arg[1] = path; + arg[2] = (VALUE)origenc; + + return rb_rescue(rb_check_realpath_emulate_try, (VALUE)arg, + rb_check_realpath_emulate_rescue, Qnil); + } + else { + return rb_check_realpath_emulate(basedir, path, origenc, mode); + } #endif /* HAVE_REALPATH */ } |