summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
-rw-r--r--file.c38
1 files changed, 31 insertions, 7 deletions
@@ -6359,7 +6359,7 @@ ruby_is_fd_loadable(int fd)
#ifndef _WIN32
int
-rb_file_load_ok(const char *path)
{
int ret = 1;
/*
@@ -6381,10 +6381,21 @@ rb_file_load_ok(const char *path)
}
rb_update_max_fd(fd);
ret = ruby_is_fd_loadable(fd);
- (void)close(fd);
return ret;
}
-#endif
static int
is_explicit_relative(const char *path)
@@ -6410,6 +6421,13 @@ copy_path_class(VALUE path, VALUE orig)
int
rb_find_file_ext(VALUE *filep, const char *const *ext)
{
const char *f = StringValueCStr(*filep);
VALUE fname = *filep, load_path, tmp;
long i, j, fnlen;
@@ -6429,7 +6447,7 @@ rb_find_file_ext(VALUE *filep, const char *const *ext)
fnlen = RSTRING_LEN(fname);
for (i=0; ext[i]; i++) {
rb_str_cat2(fname, ext[i]);
- if (rb_file_load_ok(RSTRING_PTR(fname))) {
*filep = copy_path_class(fname, *filep);
return (int)(i+1);
}
@@ -6454,7 +6472,7 @@ rb_find_file_ext(VALUE *filep, const char *const *ext)
RB_GC_GUARD(str) = rb_get_path(str);
if (RSTRING_LEN(str) == 0) continue;
rb_file_expand_path_internal(fname, str, 0, 0, tmp);
- if (rb_file_load_ok(RSTRING_PTR(tmp))) {
*filep = copy_path_class(tmp, *filep);
return (int)(j+1);
}
@@ -6469,6 +6487,12 @@ rb_find_file_ext(VALUE *filep, const char *const *ext)
VALUE
rb_find_file(VALUE path)
{
VALUE tmp, load_path;
const char *f = StringValueCStr(path);
int expanded = 0;
@@ -6481,7 +6505,7 @@ rb_find_file(VALUE path)
}
if (expanded || rb_is_absolute_path(f) || is_explicit_relative(f)) {
- if (!rb_file_load_ok(f)) return 0;
if (!expanded)
path = copy_path_class(file_expand_path_1(path), path);
return path;
@@ -6499,7 +6523,7 @@ rb_find_file(VALUE path)
if (RSTRING_LEN(str) > 0) {
rb_file_expand_path_internal(path, str, 0, 0, tmp);
f = RSTRING_PTR(tmp);
- if (rb_file_load_ok(f)) goto found;
}
}
rb_str_resize(tmp, 0);