summaryrefslogtreecommitdiff
path: root/ext/pathname/pathname.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-24 13:08:00 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-24 13:08:00 +0000
commitf21230b4916955440028e54c73eb965a44980368 (patch)
treefbefe3feacd0a015b1f429fe9339ace5cff5fc12 /ext/pathname/pathname.c
parentf2ff3eb6ec1473f0ec584557a32315ff74f8ef91 (diff)
* ext/pathname/pathname.c (path_read): Pathname#read translated from
pathname.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/pathname/pathname.c')
-rw-r--r--ext/pathname/pathname.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index bd55da1..76bbbd5 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -262,6 +262,26 @@ path_each_line(int argc, VALUE *argv, VALUE self)
}
/*
+ * 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 @@ Init_pathname()
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);