summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-09-15 12:07:43 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-09-15 12:07:43 +0000
commit363ed27fa7a9f95111e2dfa0df8ae120cfc95d8d (patch)
treea2866b17482662dec6c504439012c5f0472b99b4
parentcc9b6ba611711aca1a124e6666b9a57c7dda9d2b (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--ext/pathname/lib/pathname.rb3
-rw-r--r--ext/pathname/pathname.c15
-rw-r--r--test/pathname/test_pathname.rb2
4 files changed, 22 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 949a699fcb..8d7b0e1b5d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
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 <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
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
@@ -882,6 +882,20 @@ path_entries(VALUE self)
}
/*
+ * 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 @@ 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);
}
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index 5d22531885..ecd03d9288 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -1191,6 +1191,8 @@ class TestPathname < Test::Unit::TestCase
with_tmpchdir('rubytest-pathname') {|dir|
Pathname("d").mkdir
assert(File.directory?("d"))
+ Pathname("e").mkdir(0770)
+ assert(File.directory?("d"))
}
end