1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2013-10-21 17:06:31 +00:00
parent 1ca90beaac
commit 22a961383a
2 changed files with 9 additions and 2 deletions

9
dir.c
View file

@ -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 <code>Dir</code> 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);

2
file.c
View file

@ -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);
}