ruby-changes:17085
From: akr <ko1@a...>
Date: Tue, 24 Aug 2010 22:08:12 +0900 (JST)
Subject: [ruby-changes:17085] Ruby:r29085 (trunk): * ext/pathname/pathname.c (path_read): Pathname#read translated from
akr 2010-08-24 22:08:00 +0900 (Tue, 24 Aug 2010) New Revision: 29085 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29085 Log: * ext/pathname/pathname.c (path_read): Pathname#read translated from pathname.rb. Modified files: trunk/ChangeLog trunk/ext/pathname/lib/pathname.rb trunk/ext/pathname/pathname.c Index: ChangeLog =================================================================== --- ChangeLog (revision 29084) +++ ChangeLog (revision 29085) @@ -1,3 +1,8 @@ +Tue Aug 24 22:07:28 2010 Tanaka Akira <akr@f...> + + * ext/pathname/pathname.c (path_read): Pathname#read translated from + pathname.rb. + Tue Aug 24 10:11:04 2010 Nobuyoshi Nakada <nobu@r...> * configure.in: read API version from include/ruby/version.h. Index: ext/pathname/lib/pathname.rb =================================================================== --- ext/pathname/lib/pathname.rb (revision 29084) +++ ext/pathname/lib/pathname.rb (revision 29085) @@ -484,9 +484,6 @@ end class Pathname # * IO * - # See <tt>IO.read</tt>. Returns all data from the file, or the first +N+ bytes - # if specified. - def read(*args) IO.read(@path, *args) end # See <tt>IO.binread</tt>. Returns all the bytes from the file, or the first +N+ # if specified. Index: ext/pathname/pathname.c =================================================================== --- ext/pathname/pathname.c (revision 29084) +++ ext/pathname/pathname.c (revision 29085) @@ -262,6 +262,26 @@ } /* + * call-seq: + * pathname.read([length [, offset]]) -> string + * pathname.read([length [, offset]], open_args) -> string + * + * See <tt>IO.read</tt>. Returns all data from the file, or the first +N+ bytes + * if specified. + * + */ +static VALUE +path_read(int argc, VALUE *argv, VALUE self) +{ + VALUE args[4]; + int n; + + args[0] = get_strpath(self); + n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]); + return rb_funcall2(rb_cIO, rb_intern("read"), 1+n, args); +} + +/* * See <tt>File.atime</tt>. Returns last access time. */ static VALUE @@ -721,6 +741,7 @@ rb_define_method(rb_cPathname, "realpath", path_realpath, -1); 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, "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/