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

ruby-changes:16927

From: akr <ko1@a...>
Date: Sun, 8 Aug 2010 19:29:31 +0900 (JST)
Subject: [ruby-changes:16927] Ruby:r28923 (trunk): * ext/pathname/pathname.c (path_make_link): Pathname#make_link

akr	2010-08-08 19:29:16 +0900 (Sun, 08 Aug 2010)

  New Revision: 28923

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

  Log:
    * ext/pathname/pathname.c (path_make_link): Pathname#make_link
      translated from pathname.rb.

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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 28922)
+++ ChangeLog	(revision 28923)
@@ -1,3 +1,8 @@
+Sun Aug  8 19:16:26 2010  Tanaka Akira  <akr@f...>
+
+	* ext/pathname/pathname.c (path_make_link): Pathname#make_link
+	  translated from pathname.rb.
+
 Sun Aug  8 16:42:48 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/rubygems.rb (Gem.find_files): reverted to use globbing.
Index: ext/pathname/lib/pathname.rb
===================================================================
--- ext/pathname/lib/pathname.rb	(revision 28922)
+++ ext/pathname/lib/pathname.rb	(revision 28923)
@@ -512,9 +512,6 @@
 
 class Pathname    # * File *
 
-  # See <tt>File.link</tt>.  Creates a hard link.
-  def make_link(old) File.link(old, @path) end
-
   # See <tt>File.open</tt>.  Opens the file for reading or writing.
   def open(*args, &block) # :yield: file
     File.open(@path, *args, &block)
Index: ext/pathname/pathname.c
===================================================================
--- ext/pathname/pathname.c	(revision 28922)
+++ ext/pathname/pathname.c	(revision 28923)
@@ -325,6 +325,18 @@
 }
 
 /*
+ * call-seq:
+ *   pathname.make_link(old)
+ *
+ * See <tt>File.link</tt>.  Creates a hard link at _pathname_.
+ */
+static VALUE
+path_make_link(VALUE self, VALUE old)
+{
+    return rb_funcall(rb_cFile, rb_intern("link"), 2, old, get_strpath(self));
+}
+
+/*
  * == Pathname
  *
  * Pathname represents a pathname which locates a file in a filesystem.
@@ -534,4 +546,5 @@
     rb_define_method(rb_cPathname, "fnmatch", path_fnmatch, -1);
     rb_define_method(rb_cPathname, "fnmatch?", path_fnmatch, -1);
     rb_define_method(rb_cPathname, "ftype", path_ftype, 0);
+    rb_define_method(rb_cPathname, "make_link", path_make_link, 1);
 }

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

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