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

ruby-changes:17097

From: akr <ko1@a...>
Date: Wed, 25 Aug 2010 22:11:58 +0900 (JST)
Subject: [ruby-changes:17097] Ruby:r29097 (trunk): * ext/pathname/pathname.c (path_binread): Pathname#binread translated

akr	2010-08-25 22:11:43 +0900 (Wed, 25 Aug 2010)

  New Revision: 29097

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

  Log:
    * ext/pathname/pathname.c (path_binread): Pathname#binread translated
      from pathname.rb.

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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29096)
+++ ChangeLog	(revision 29097)
@@ -1,3 +1,8 @@
+Wed Aug 25 22:11:11 2010  Tanaka Akira  <akr@f...>
+
+	* ext/pathname/pathname.c (path_binread): Pathname#binread translated
+	  from pathname.rb.
+
 Wed Aug 25 03:42:43 2010  NAKAMURA Usaku  <usa@r...>
 
 	* ext/dl/cfunc.c (rb_dlcfunc_call): workaround for VC9 for x64.
Index: ext/pathname/lib/pathname.rb
===================================================================
--- ext/pathname/lib/pathname.rb	(revision 29096)
+++ ext/pathname/lib/pathname.rb	(revision 29097)
@@ -485,10 +485,6 @@
 
 class Pathname    # * IO *
 
-  # See <tt>IO.binread</tt>.  Returns all the bytes from the file, or the first +N+
-  # if specified.
-  def binread(*args) IO.binread(@path, *args) end
-
   # See <tt>IO.readlines</tt>.  Returns all the lines from the file.
   def readlines(*args) IO.readlines(@path, *args) end
 
Index: ext/pathname/pathname.c
===================================================================
--- ext/pathname/pathname.c	(revision 29096)
+++ ext/pathname/pathname.c	(revision 29097)
@@ -282,6 +282,25 @@
 }
 
 /*
+ * call-seq:
+ *   pathname.binread([length [, offset]]) -> string
+ *        
+ * See <tt>IO.binread</tt>.  Returns all the bytes from the file, or the first +N+
+ * if specified.
+ *
+ */
+static VALUE
+path_binread(int argc, VALUE *argv, VALUE self)
+{
+    VALUE args[3];
+    int n;
+
+    args[0] = get_strpath(self);
+    n = rb_scan_args(argc, argv, "02", &args[1], &args[2]);
+    return rb_funcall2(rb_cIO, rb_intern("binread"), 1+n, args);
+}
+
+/*
  * See <tt>File.atime</tt>.  Returns last access time.
  */
 static VALUE
@@ -742,6 +761,7 @@
     rb_define_method(rb_cPathname, "realdirpath", path_realdirpath, -1);
     rb_define_method(rb_cPathname, "each_line", path_each_line, -1);
     rb_define_method(rb_cPathname, "read", path_read, -1);
+    rb_define_method(rb_cPathname, "binread", path_binread, -1);
     rb_define_method(rb_cPathname, "atime", path_atime, 0);
     rb_define_method(rb_cPathname, "ctime", path_ctime, 0);
     rb_define_method(rb_cPathname, "mtime", path_mtime, 0);

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

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