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

ruby-changes:16956

From: akr <ko1@a...>
Date: Tue, 10 Aug 2010 20:56:43 +0900 (JST)
Subject: [ruby-changes:16956] Ruby:r28952 (trunk): * ext/pathname/pathname.c (path_rename): Pathname#rename translated

akr	2010-08-10 20:45:57 +0900 (Tue, 10 Aug 2010)

  New Revision: 28952

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

  Log:
    * ext/pathname/pathname.c (path_rename): Pathname#rename translated
      from pathname.rb.

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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 28951)
+++ ChangeLog	(revision 28952)
@@ -1,3 +1,8 @@
+Tue Aug 10 20:45:35 2010  Tanaka Akira  <akr@f...>
+
+	* ext/pathname/pathname.c (path_rename): Pathname#rename translated
+	  from pathname.rb.
+
 Tue Aug 10 20:16:19 2010  NAKAMURA Usaku  <usa@r...>
 
 	* ext/dl/win32/lib/win32/resolv.rb (get_info): get rid of a warning.
Index: ext/pathname/lib/pathname.rb
===================================================================
--- ext/pathname/lib/pathname.rb	(revision 28951)
+++ ext/pathname/lib/pathname.rb	(revision 28952)
@@ -512,9 +512,6 @@
 
 class Pathname    # * File *
 
-  # See <tt>File.rename</tt>.  Rename the file.
-  def rename(to) File.rename(@path, to) end
-
   # See <tt>File.stat</tt>.  Returns a <tt>File::Stat</tt> object.
   def stat() File.stat(@path) end
 
Index: ext/pathname/pathname.c
===================================================================
--- ext/pathname/pathname.c	(revision 28951)
+++ ext/pathname/pathname.c	(revision 28952)
@@ -367,6 +367,15 @@
 }
 
 /*
+ * See <tt>File.rename</tt>.  Rename the file.
+ */
+static VALUE
+path_rename(VALUE self, VALUE to)
+{
+    return rb_funcall(rb_cFile, rb_intern("rename"), 2, get_strpath(self), to);
+}
+
+/*
  * == Pathname
  *
  * Pathname represents a pathname which locates a file in a filesystem.
@@ -579,4 +588,5 @@
     rb_define_method(rb_cPathname, "make_link", path_make_link, 1);
     rb_define_method(rb_cPathname, "open", path_open, -1);
     rb_define_method(rb_cPathname, "readlink", path_readlink, 0);
+    rb_define_method(rb_cPathname, "rename", path_rename, 1);
 }

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

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