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

ruby-changes:17023

From: akr <ko1@a...>
Date: Tue, 17 Aug 2010 13:03:22 +0900 (JST)
Subject: [ruby-changes:17023] Ruby:r29020 (trunk): * ext/pathname/pathname.c (path_dirname): Pathname#dirname translated

akr	2010-08-17 13:02:32 +0900 (Tue, 17 Aug 2010)

  New Revision: 29020

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

  Log:
    * ext/pathname/pathname.c (path_dirname): Pathname#dirname translated
      from pathname.rb.

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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29019)
+++ ChangeLog	(revision 29020)
@@ -1,3 +1,8 @@
+Tue Aug 17 13:00:07 2010  Tanaka Akira  <akr@f...>
+
+	* ext/pathname/pathname.c (path_dirname): Pathname#dirname translated
+	  from pathname.rb.
+
 Tue Aug 17 07:50:37 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/readline/extconf.rb: check functions more.
Index: ext/pathname/lib/pathname.rb
===================================================================
--- ext/pathname/lib/pathname.rb	(revision 29019)
+++ ext/pathname/lib/pathname.rb	(revision 29020)
@@ -512,9 +512,6 @@
 
 class Pathname    # * File *
 
-  # See <tt>File.dirname</tt>.  Returns all but the last component of the path.
-  def dirname() self.class.new(File.dirname(@path)) end
-
   # See <tt>File.extname</tt>.  Returns the file's extension.
   def extname() File.extname(@path) end
 
Index: ext/pathname/pathname.c
===================================================================
--- ext/pathname/pathname.c	(revision 29019)
+++ ext/pathname/pathname.c	(revision 29020)
@@ -439,6 +439,17 @@
 }
 
 /*
+ * See <tt>File.dirname</tt>.  Returns all but the last component of the path.
+ */
+static VALUE
+path_dirname(VALUE self)
+{
+    VALUE str = get_strpath(self);
+    str = rb_funcall(rb_cFile, rb_intern("dirname"), 1, str);
+    return rb_class_new_instance(1, &str, rb_obj_class(self));
+}
+
+/*
  * == Pathname
  *
  * Pathname represents a pathname which locates a file in a filesystem.
@@ -658,4 +669,5 @@
     rb_define_method(rb_cPathname, "truncate", path_truncate, 1);
     rb_define_method(rb_cPathname, "utime", path_utime, 2);
     rb_define_method(rb_cPathname, "basename", path_basename, -1);
+    rb_define_method(rb_cPathname, "dirname", path_dirname, 0);
 }

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

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