summaryrefslogtreecommitdiff
path: root/ext/pathname
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-26 20:16:25 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-26 20:16:25 +0000
commit9eb726258965a35191b8b84a25448d5dd203faea (patch)
treea7a191cc4e0aa16fe279b843b33c8ef2584a6395 /ext/pathname
parent71cf670f0fc5556a51d6e209a14cceafcf6550d7 (diff)
* ext/pathname/pathname.c (path_sysopen): Pathname#sysopen translated
from pathname.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/pathname')
-rw-r--r--ext/pathname/lib/pathname.rb6
-rw-r--r--ext/pathname/pathname.c19
2 files changed, 19 insertions, 6 deletions
diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb
index b4c701a084..c9bf0c5fb8 100644
--- a/ext/pathname/lib/pathname.rb
+++ b/ext/pathname/lib/pathname.rb
@@ -483,12 +483,6 @@ class Pathname
end
end
-class Pathname # * IO *
-
- # See <tt>IO.sysopen</tt>.
- def sysopen(*args) IO.sysopen(@path, *args) end
-end
-
class Pathname # * FileTest *
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index 2918ef0ecb..f5ba6dc1ae 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -321,6 +321,24 @@ path_readlines(int argc, VALUE *argv, VALUE self)
}
/*
+ * call-seq:
+ * pathname.sysopen([mode, [perm]]) -> fixnum
+ *
+ * See <tt>IO.sysopen</tt>.
+ *
+ */
+static VALUE
+path_sysopen(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("sysopen"), 1+n, args);
+}
+
+/*
* See <tt>File.atime</tt>. Returns last access time.
*/
static VALUE
@@ -783,6 +801,7 @@ Init_pathname()
rb_define_method(rb_cPathname, "read", path_read, -1);
rb_define_method(rb_cPathname, "binread", path_binread, -1);
rb_define_method(rb_cPathname, "readlines", path_readlines, -1);
+ rb_define_method(rb_cPathname, "sysopen", path_sysopen, -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);