diff --git a/ChangeLog b/ChangeLog index 4f5f4b159e..c7853b63b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Aug 27 05:11:51 2010 Tanaka Akira + + * ext/pathname/pathname.c (path_sysopen): Pathname#sysopen translated + from pathname.rb. + Thu Aug 26 22:53:56 2010 Nobuyoshi Nakada * array.c (rb_ary_shuffle): rdoc fix. argument name was missing. 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 IO.sysopen. - 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 @@ -320,6 +320,24 @@ path_readlines(int argc, VALUE *argv, VALUE self) return rb_funcall2(rb_cIO, rb_intern("readlines"), 1+n, args); } +/* + * call-seq: + * pathname.sysopen([mode, [perm]]) -> fixnum + * + * See IO.sysopen. + * + */ +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 File.atime. Returns last access time. */ @@ -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);