summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-02 19:11:01 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-02 19:11:01 +0900
commit4e01ab342a4b1478255eee09ddbb5e9fe46a88b9 (patch)
tree50a5850613f3f1594d3935daf9cb1ba5c09bbb2f /file.c
parent1a5205536f0c0d6021450b11722919211847df86 (diff)
Revert "Removed deprecated Dir.exists? and File.exists?"
This reverts commit 1a5205536f0c0d6021450b11722919211847df86.
Diffstat (limited to 'file.c')
-rw-r--r--file.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/file.c b/file.c
index c64ec8cf7f2..0c599b08956 100644
--- a/file.c
+++ b/file.c
@@ -1787,6 +1787,23 @@ rb_file_exist_p(VALUE obj, VALUE fname)
return Qtrue;
}
+/* :nodoc: */
+static VALUE
+rb_file_exists_p(VALUE obj, VALUE fname)
+{
+ const char *s = "FileTest#exist?";
+ if (obj == rb_mFileTest) {
+ s = "FileTest.exist?";
+ }
+ else if (obj == rb_cFile ||
+ (RB_TYPE_P(obj, T_CLASS) &&
+ RTEST(rb_class_inherited_p(obj, rb_cFile)))) {
+ s = "File.exist?";
+ }
+ rb_warn_deprecated("%.*ss?", s, (int)(strlen(s)-1), s);
+ return rb_file_exist_p(obj, fname);
+}
+
/*
* call-seq:
* File.readable?(file_name) -> true or false
@@ -6452,6 +6469,7 @@ Init_File(void)
define_filetest_function("directory?", rb_file_directory_p, 1);
define_filetest_function("exist?", rb_file_exist_p, 1);
+ define_filetest_function("exists?", rb_file_exists_p, 1);
define_filetest_function("readable?", rb_file_readable_p, 1);
define_filetest_function("readable_real?", rb_file_readable_real_p, 1);
define_filetest_function("world_readable?", rb_file_world_readable_p, 1);