[前][次][番号順一覧][スレッド一覧]

ruby-changes:31301

From: nobu <ko1@a...>
Date: Tue, 22 Oct 2013 02:06:37 +0900 (JST)
Subject: [ruby-changes:31301] nobu:r43380 (trunk): dir.c: warn Dir.exists?

nobu	2013-10-22 02:06:31 +0900 (Tue, 22 Oct 2013)

  New Revision: 43380

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43380

  Log:
    dir.c: warn Dir.exists?
    
    * dir.c (rb_dir_exists_p): warn deprecated name.  [Bug #9041]

  Modified files:
    trunk/dir.c
    trunk/file.c
Index: dir.c
===================================================================
--- dir.c	(revision 43379)
+++ dir.c	(revision 43380)
@@ -2157,6 +2157,13 @@ rb_file_directory_p() https://github.com/ruby/ruby/blob/trunk/dir.c#L2157
 }
 #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) https://github.com/ruby/ruby/blob/trunk/dir.c#L2213
     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);
Index: file.c
===================================================================
--- file.c	(revision 43379)
+++ file.c	(revision 43380)
@@ -1409,7 +1409,7 @@ rb_file_exists_p(VALUE obj, VALUE fname) https://github.com/ruby/ruby/blob/trunk/file.c#L1409
 	      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);
 }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]