From 363ed27fa7a9f95111e2dfa0df8ae120cfc95d8d Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 15 Sep 2010 12:07:43 +0000 Subject: * ext/pathname/pathname.c (path_mkdir): Pathname#mkdir translated from pathname.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/pathname/lib/pathname.rb | 3 --- ext/pathname/pathname.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'ext') diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb index efe45afd6e..fdbafc512b 100644 --- a/ext/pathname/lib/pathname.rb +++ b/ext/pathname/lib/pathname.rb @@ -494,9 +494,6 @@ class Pathname # * Dir * Dir.foreach(@path) {|f| yield self.class.new(f) } end - # See Dir.mkdir. Create the referenced directory. - def mkdir(*args) Dir.mkdir(@path, *args) end - # See Dir.rmdir. Remove the referenced directory. def rmdir() Dir.rmdir(@path) end diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index cfeb94b1b7..1eeddfb503 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -881,6 +881,20 @@ path_entries(VALUE self) return ary; } +/* + * See Dir.mkdir. Create the referenced directory. + */ +static VALUE +path_mkdir(int argc, VALUE *argv, VALUE self) +{ + VALUE str = get_strpath(self); + VALUE vmode; + if (rb_scan_args(argc, argv, "01", &vmode) == 0) + return rb_funcall(rb_cDir, rb_intern("mkdir"), 1, str); + else + return rb_funcall(rb_cDir, rb_intern("mkdir"), 2, str, vmode); +} + /* * == Pathname * @@ -1138,4 +1152,5 @@ Init_pathname() rb_define_singleton_method(rb_cPathname, "getwd", path_s_getwd, 0); rb_define_singleton_method(rb_cPathname, "pwd", path_s_getwd, 0); rb_define_method(rb_cPathname, "entries", path_entries, 0); + rb_define_method(rb_cPathname, "mkdir", path_mkdir, -1); } -- cgit v1.2.3