ruby-changes:17260
From: akr <ko1@a...>
Date: Wed, 15 Sep 2010 21:16:04 +0900 (JST)
Subject: [ruby-changes:17260] Ruby:r29261 (trunk): * ext/pathname/pathname.c (path_mkdir): Pathname#mkdir translated
akr 2010-09-15 21:07:43 +0900 (Wed, 15 Sep 2010) New Revision: 29261 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29261 Log: * ext/pathname/pathname.c (path_mkdir): Pathname#mkdir translated from pathname.rb. Modified files: trunk/ChangeLog trunk/ext/pathname/lib/pathname.rb trunk/ext/pathname/pathname.c trunk/test/pathname/test_pathname.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 29260) +++ ChangeLog (revision 29261) @@ -1,3 +1,8 @@ +Wed Sep 15 21:07:06 2010 Tanaka Akira <akr@f...> + + * ext/pathname/pathname.c (path_mkdir): Pathname#mkdir translated + from pathname.rb. + Wed Sep 15 13:37:00 2010 URABE Shyouhei <shyouhei@r...> * test/net/imap/test_imap.rb: "localhost" not guaranteed to Index: ext/pathname/lib/pathname.rb =================================================================== --- ext/pathname/lib/pathname.rb (revision 29260) +++ ext/pathname/lib/pathname.rb (revision 29261) @@ -494,9 +494,6 @@ Dir.foreach(@path) {|f| yield self.class.new(f) } end - # See <tt>Dir.mkdir</tt>. Create the referenced directory. - def mkdir(*args) Dir.mkdir(@path, *args) end - # See <tt>Dir.rmdir</tt>. Remove the referenced directory. def rmdir() Dir.rmdir(@path) end Index: ext/pathname/pathname.c =================================================================== --- ext/pathname/pathname.c (revision 29260) +++ ext/pathname/pathname.c (revision 29261) @@ -882,6 +882,20 @@ } /* + * See <tt>Dir.mkdir</tt>. 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 * * Pathname represents a pathname which locates a file in a filesystem. @@ -1138,4 +1152,5 @@ 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); } Index: test/pathname/test_pathname.rb =================================================================== --- test/pathname/test_pathname.rb (revision 29260) +++ test/pathname/test_pathname.rb (revision 29261) @@ -1191,6 +1191,8 @@ with_tmpchdir('rubytest-pathname') {|dir| Pathname("d").mkdir assert(File.directory?("d")) + Pathname("e").mkdir(0770) + assert(File.directory?("d")) } end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/