aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'file.c')
-rw-r--r--file.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/file.c b/file.c
index 982a30c4a3..884ec8518e 100644
--- a/file.c
+++ b/file.c
@@ -1414,6 +1414,13 @@ eaccess(const char *path, int mode)
}
#endif
+static int
+rb_eaccess(VALUE fname, int mode)
+{
+ FilePathValue(fname);
+ fname = rb_str_encode_ospath(fname);
+ return eaccess(StringValueCStr(fname), mode);
+}
/*
* Document-class: FileTest
@@ -1658,9 +1665,7 @@ rb_file_exists_p(VALUE obj, VALUE fname)
static VALUE
rb_file_readable_p(VALUE obj, VALUE fname)
{
- FilePathValue(fname);
- fname = rb_str_encode_ospath(fname);
- if (eaccess(StringValueCStr(fname), R_OK) < 0) return Qfalse;
+ if (rb_eaccess(fname, R_OK) < 0) return Qfalse;
return Qtrue;
}
@@ -1730,9 +1735,7 @@ rb_file_world_readable_p(VALUE obj, VALUE fname)
static VALUE
rb_file_writable_p(VALUE obj, VALUE fname)
{
- FilePathValue(fname);
- fname = rb_str_encode_ospath(fname);
- if (eaccess(StringValueCStr(fname), W_OK) < 0) return Qfalse;
+ if (rb_eaccess(fname, W_OK) < 0) return Qfalse;
return Qtrue;
}
@@ -1794,9 +1797,7 @@ rb_file_world_writable_p(VALUE obj, VALUE fname)
static VALUE
rb_file_executable_p(VALUE obj, VALUE fname)
{
- FilePathValue(fname);
- fname = rb_str_encode_ospath(fname);
- if (eaccess(StringValueCStr(fname), X_OK) < 0) return Qfalse;
+ if (rb_eaccess(fname, X_OK) < 0) return Qfalse;
return Qtrue;
}