summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-18 02:07:31 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-18 02:07:31 +0000
commit125514995cb83f18464f4b17a7272fe19099e939 (patch)
treed5e534cd272b29ac61a098ec492515cbf230383b /dir.c
parent7836e8ade3444b7c43259138bff5db4bc40986e2 (diff)
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* hash.c (Init_Hash): remove custom "hash" and "eql?". * lib/set.rb (Set::eql): wrong definition. [ruby-dev:25207] * object.c (rb_obj_id_obsolete): warn always. * eval.c (rb_enable_super): ditto. * lib/set.rb (Set#==): [ruby-dev:25206] * lib/pstore.rb (PStore#transaction): Use the empty content when a file is not found. [ruby-dev:24561] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/dir.c b/dir.c
index 330a9c5..97b78cb 100644
--- a/dir.c
+++ b/dir.c
@@ -1318,6 +1318,22 @@ dir_s_glob(argc, argv, obj)
return rb_push_glob(str, flags);
}
+static VALUE
+dir_open_dir(path)
+ VALUE path;
+{
+ struct dir_data *dp;
+ VALUE dir = rb_funcall(rb_cDir, rb_intern("open"), 1, path);
+
+ if (TYPE(dir) != T_DATA ||
+ RDATA(dir)->dfree != (RUBY_DATA_FUNC)free_dir) {
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected Dir)",
+ rb_obj_classname(dir));
+ }
+ return dir;
+}
+
+
/*
* call-seq:
* Dir.foreach( dirname ) {| filename | block } => nil
@@ -1341,7 +1357,7 @@ dir_foreach(io, dirname)
{
VALUE dir;
- dir = rb_funcall(rb_cDir, rb_intern("open"), 1, dirname);
+ dir = dir_open_dir(dirname);
rb_ensure(dir_each, dir, dir_close, dir);
return Qnil;
}
@@ -1363,7 +1379,7 @@ dir_entries(io, dirname)
{
VALUE dir;
- dir = rb_funcall(rb_cDir, rb_intern("open"), 1, dirname);
+ dir = dir_open_dir(dirname);
return rb_ensure(rb_Array, dir, dir_close, dir);
}