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

ruby-changes:16837

From: akr <ko1@a...>
Date: Mon, 2 Aug 2010 05:35:50 +0900 (JST)
Subject: [ruby-changes:16837] Ruby:r28831 (trunk): * ext/pathname/pathname.c (path_realdirpath): Pathname#realdirpath

akr	2010-08-02 05:35:33 +0900 (Mon, 02 Aug 2010)

  New Revision: 28831

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

  Log:
    * ext/pathname/pathname.c (path_realdirpath): Pathname#realdirpath
      translated from pathname.rb.

  Modified files:
    trunk/ChangeLog
    trunk/ext/pathname/lib/pathname.rb
    trunk/ext/pathname/pathname.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 28830)
+++ ChangeLog	(revision 28831)
@@ -1,3 +1,8 @@
+Mon Aug  2 05:34:48 2010  Tanaka Akira  <akr@f...>
+
+	* ext/pathname/pathname.c (path_realdirpath): Pathname#realdirpath
+	  translated from pathname.rb.
+
 Sun Aug  1 23:04:49 2010  Tanaka Akira  <akr@f...>
 
 	* lib/pp.rb: describe superclasses explicitly.
Index: ext/pathname/lib/pathname.rb
===================================================================
--- ext/pathname/lib/pathname.rb	(revision 28830)
+++ ext/pathname/lib/pathname.rb	(revision 28831)
@@ -179,16 +179,6 @@
   end
   private :cleanpath_conservative
 
-  #
-  # Returns the real (absolute) pathname of +self+ in the actual filesystem.
-  # The real pathname doesn't contain symlinks or useless dots.
-  #
-  # The last component of the real pathname can be nonexistent.
-  #
-  def realdirpath(basedir=nil)
-    self.class.new(File.realdirpath(@path, basedir))
-  end
-
   # #parent returns the parent directory.
   #
   # This is same as <tt>self + '..'</tt>.
Index: ext/pathname/pathname.c
===================================================================
--- ext/pathname/pathname.c	(revision 28830)
+++ ext/pathname/pathname.c	(revision 28831)
@@ -216,6 +216,21 @@
 }
 
 /*
+ * Returns the real (absolute) pathname of +self+ in the actual filesystem.
+ * The real pathname doesn't contain symlinks or useless dots.
+ * 
+ * The last component of the real pathname can be nonexistent.
+ */
+static VALUE
+path_realdirpath(int argc, VALUE *argv, VALUE self)
+{
+    VALUE basedir, str;
+    rb_scan_args(argc, argv, "01", &basedir);
+    str = rb_funcall(rb_cFile, rb_intern("realdirpath"), 2, get_strpath(self), basedir);
+    return rb_class_new_instance(1, &str, rb_obj_class(self));
+}
+
+/*
  * == Pathname
  *
  * Pathname represents a pathname which locates a file in a filesystem.
@@ -414,4 +429,5 @@
     rb_define_method(rb_cPathname, "sub", path_sub, -1);
     rb_define_method(rb_cPathname, "sub_ext", path_sub_ext, 1);
     rb_define_method(rb_cPathname, "realpath", path_realpath, -1);
+    rb_define_method(rb_cPathname, "realdirpath", path_realdirpath, -1);
 }

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

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