summaryrefslogtreecommitdiff
path: root/ext/pathname/pathname.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-25 13:11:43 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-25 13:11:43 +0000
commit2034fe610fd9da3781f4a1e39079128da812748c (patch)
tree53c5283a509e76e2ddd8ff490731bacc643c113b /ext/pathname/pathname.c
parent2531892cbc997ae25a121e21cca321722ec663c3 (diff)
* ext/pathname/pathname.c (path_binread): Pathname#binread translated
from pathname.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/pathname/pathname.c')
-rw-r--r--ext/pathname/pathname.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index 76bbbd5..874581d 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -282,6 +282,25 @@ path_read(int argc, VALUE *argv, VALUE self)
}
/*
+ * 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 @@ Init_pathname()
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);