summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/pathname/lib/pathname.rb4
-rw-r--r--ext/pathname/pathname.c13
2 files changed, 13 insertions, 4 deletions
diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb
index ac8d106e11..1f29f38376 100644
--- a/ext/pathname/lib/pathname.rb
+++ b/ext/pathname/lib/pathname.rb
@@ -494,10 +494,6 @@ class Pathname # * Dir *
Dir.foreach(@path) {|f| yield self.class.new(f) }
end
- # See <tt>Dir.open</tt>.
- def opendir(&block) # :yield: dir
- Dir.open(@path, &block)
- end
end
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index cc1fd8c678..92c09555ee 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -905,6 +905,18 @@ path_rmdir(VALUE self)
}
/*
+ * See <tt>Dir.open</tt>.
+ */
+static VALUE
+path_opendir(VALUE self)
+{
+ VALUE args[1];
+
+ args[0] = get_strpath(self);
+ return rb_block_call(rb_cDir, rb_intern("open"), 1, args, 0, 0);
+}
+
+/*
* == Pathname
*
* Pathname represents a pathname which locates a file in a filesystem.
@@ -1163,4 +1175,5 @@ Init_pathname()
rb_define_method(rb_cPathname, "entries", path_entries, 0);
rb_define_method(rb_cPathname, "mkdir", path_mkdir, -1);
rb_define_method(rb_cPathname, "rmdir", path_rmdir, 0);
+ rb_define_method(rb_cPathname, "opendir", path_opendir, 0);
}