mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Removed deprecated Dir.exists? and File.exists?
This commit is contained in:
parent
9e94cd18fc
commit
1a5205536f
3 changed files with 6 additions and 29 deletions
9
dir.c
9
dir.c
|
@ -3342,14 +3342,6 @@ rb_file_directory_p(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* :nodoc: */
|
|
||||||
static VALUE
|
|
||||||
rb_dir_exists_p(VALUE obj, VALUE fname)
|
|
||||||
{
|
|
||||||
rb_warn_deprecated("Dir.exists?", "Dir.exist?");
|
|
||||||
return rb_file_directory_p(obj, fname);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
nogvl_dir_empty_p(void *ptr)
|
nogvl_dir_empty_p(void *ptr)
|
||||||
{
|
{
|
||||||
|
@ -3478,7 +3470,6 @@ Init_Dir(void)
|
||||||
rb_define_singleton_method(rb_cDir,"home", dir_s_home, -1);
|
rb_define_singleton_method(rb_cDir,"home", dir_s_home, -1);
|
||||||
|
|
||||||
rb_define_singleton_method(rb_cDir,"exist?", rb_file_directory_p, 1);
|
rb_define_singleton_method(rb_cDir,"exist?", rb_file_directory_p, 1);
|
||||||
rb_define_singleton_method(rb_cDir,"exists?", rb_dir_exists_p, 1);
|
|
||||||
rb_define_singleton_method(rb_cDir,"empty?", rb_dir_s_empty_p, 1);
|
rb_define_singleton_method(rb_cDir,"empty?", rb_dir_s_empty_p, 1);
|
||||||
|
|
||||||
rb_define_singleton_method(rb_cFile,"fnmatch", file_s_fnmatch, -1);
|
rb_define_singleton_method(rb_cFile,"fnmatch", file_s_fnmatch, -1);
|
||||||
|
|
18
file.c
18
file.c
|
@ -1787,23 +1787,6 @@ rb_file_exist_p(VALUE obj, VALUE fname)
|
||||||
return Qtrue;
|
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:
|
* call-seq:
|
||||||
* File.readable?(file_name) -> true or false
|
* File.readable?(file_name) -> true or false
|
||||||
|
@ -6469,7 +6452,6 @@ Init_File(void)
|
||||||
|
|
||||||
define_filetest_function("directory?", rb_file_directory_p, 1);
|
define_filetest_function("directory?", rb_file_directory_p, 1);
|
||||||
define_filetest_function("exist?", rb_file_exist_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?", rb_file_readable_p, 1);
|
||||||
define_filetest_function("readable_real?", rb_file_readable_real_p, 1);
|
define_filetest_function("readable_real?", rb_file_readable_real_p, 1);
|
||||||
define_filetest_function("world_readable?", rb_file_world_readable_p, 1);
|
define_filetest_function("world_readable?", rb_file_world_readable_p, 1);
|
||||||
|
|
|
@ -961,13 +961,17 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_warn_deprecated_backwards_compatibility_category
|
def test_warn_deprecated_backwards_compatibility_category
|
||||||
warning = capture_warning_warn { Dir.exists?("non-existent") }
|
skip "no method to test"
|
||||||
|
|
||||||
|
warning = capture_warning_warn { }
|
||||||
|
|
||||||
assert_match(/deprecated/, warning[0])
|
assert_match(/deprecated/, warning[0])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_warn_deprecated_category
|
def test_warn_deprecated_category
|
||||||
warning = capture_warning_warn(category: true) { Dir.exists?("non-existent") }
|
skip "no method to test"
|
||||||
|
|
||||||
|
warning = capture_warning_warn(category: true) { }
|
||||||
|
|
||||||
assert_equal :deprecated, warning[0][1]
|
assert_equal :deprecated, warning[0][1]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue