Permalink
Browse files

* 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
  • Loading branch information...
akr committed Sep 15, 2010
1 parent cc9b6ba commit 363ed27fa7a9f95111e2dfa0df8ae120cfc95d8d
Showing with 22 additions and 3 deletions.
  1. +5 −0 ChangeLog
  2. +0 −3 ext/pathname/lib/pathname.rb
  3. +15 −0 ext/pathname/pathname.c
  4. +2 −0 test/pathname/test_pathname.rb
View
@@ -1,3 +1,8 @@
+Wed Sep 15 21:07:06 2010 Tanaka Akira <akr@fsij.org>
+
+ * ext/pathname/pathname.c (path_mkdir): Pathname#mkdir translated
+ from pathname.rb.
+
Wed Sep 15 13:37:00 2010 URABE Shyouhei <shyouhei@ruby-lang.org>
* test/net/imap/test_imap.rb: "localhost" not guaranteed to
@@ -494,9 +494,6 @@ def each_entry(&block) # :yield: pathname
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
View
@@ -881,6 +881,20 @@ path_entries(VALUE self)
return ary;
}
+/*
+ * 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
*
@@ -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);
}
@@ -1191,6 +1191,8 @@ def test_mkdir
with_tmpchdir('rubytest-pathname') {|dir|
Pathname("d").mkdir
assert(File.directory?("d"))
+ Pathname("e").mkdir(0770)
+ assert(File.directory?("d"))
}
end

0 comments on commit 363ed27

Please sign in to comment.