summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-23 14:18:30 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-23 14:18:30 (GMT)
commit78a73a538d6779eddbaac947c3d50361b2082a3b (patch)
tree946fe8d31084d30f6dcd24e9e056afe7f63b380f /dir.c
parent2ffb87995a33cdc7ba609a4b867f03f18da0c3b3 (diff)
dir.c: don't raise after close
* dir.c (dir_close): don't raise on dobule close for consistent to IO#close. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/dir.c b/dir.c
index 9fbbcb1..ab36950 100644
--- a/dir.c
+++ b/dir.c
@@ -543,11 +543,16 @@ dir_closed(void)
}
static struct dir_data *
-dir_check(VALUE dir)
+dir_get(VALUE dir)
{
- struct dir_data *dirp;
rb_check_frozen(dir);
- dirp = rb_check_typeddata(dir, &dir_data_type);
+ return rb_check_typeddata(dir, &dir_data_type);
+}
+
+static struct dir_data *
+dir_check(VALUE dir)
+{
+ struct dir_data *dirp = dir_get(dir);
if (!dirp->dir) dir_closed();
return dirp;
}
@@ -831,7 +836,8 @@ dir_close(VALUE dir)
{
struct dir_data *dirp;
- GetDIR(dir, dirp);
+ dirp = dir_get(dir);
+ if (!dirp->dir) return Qnil;
closedir(dirp->dir);
dirp->dir = NULL;