From 22a961383a4c3519f5d807f0986168ec1ec2bebf Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 21 Oct 2013 17:06:31 +0000 Subject: [PATCH] dir.c: warn Dir.exists? * dir.c (rb_dir_exists_p): warn deprecated name. [Bug #9041] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- dir.c | 9 ++++++++- file.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dir.c b/dir.c index 40e5537ceb..3844087667 100644 --- a/dir.c +++ b/dir.c @@ -2157,6 +2157,13 @@ rb_file_directory_p() } #endif +static VALUE +rb_dir_exists_p(VALUE obj, VALUE fname) +{ + rb_warning("Dir.exists? is a deprecated name, use Dir.exist? instead"); + return rb_file_directory_p(obj, fname); +} + /* * Objects of class Dir are directory streams representing * directories in the underlying file system. They provide a variety of @@ -2206,7 +2213,7 @@ Init_Dir(void) rb_define_singleton_method(rb_cDir,"glob", dir_s_glob, -1); rb_define_singleton_method(rb_cDir,"[]", dir_s_aref, -1); rb_define_singleton_method(rb_cDir,"exist?", rb_file_directory_p, 1); - rb_define_singleton_method(rb_cDir,"exists?", rb_file_directory_p, 1); + rb_define_singleton_method(rb_cDir,"exists?", rb_dir_exists_p, 1); rb_define_singleton_method(rb_cFile,"fnmatch", file_s_fnmatch, -1); rb_define_singleton_method(rb_cFile,"fnmatch?", file_s_fnmatch, -1); diff --git a/file.c b/file.c index a6b5373f09..acbaa5c5f4 100644 --- a/file.c +++ b/file.c @@ -1409,7 +1409,7 @@ rb_file_exists_p(VALUE obj, VALUE fname) RTEST(rb_class_inherited_p(obj, rb_cFile)))) { s = "File."; } - rb_warning("%sexists? is deprecated name, use %sexist? instead", s, s); + rb_warning("%sexists? is a deprecated name, use %sexist? instead", s, s); return rb_file_exist_p(obj, fname); }