summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-21 07:40:47 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-21 07:40:47 +0000
commitccc9841a826962ec8fccbf1bdc09b3747432ece9 (patch)
treee2d7bb21f7fb2b07948d6db8d04a02ab98b5ea55 /dir.c
parent4791b2bc2289e36c33c7ba0e2c9f09a5f509f28d (diff)
prefer rb_syserr_fail
* dir.c (dir_initialize, dir_read): prefer rb_syserr_fail over rb_sys_fail. * io.c (ruby_dup, rb_sysopen): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/dir.c b/dir.c
index 90fc1efe..737470c 100644
--- a/dir.c
+++ b/dir.c
@@ -526,11 +526,12 @@ dir_initialize(int argc, VALUE *argv, VALUE dir)
path = RSTRING_PTR(dirname);
dp->dir = opendir(path);
if (dp->dir == NULL) {
- if (rb_gc_for_fd(errno)) {
+ int e = errno;
+ if (rb_gc_for_fd(e)) {
dp->dir = opendir(path);
}
#ifdef HAVE_GETATTRLIST
- else if (errno == EIO) {
+ else if (e == EIO) {
u_int32_t attrbuf[1];
struct attrlist al = {ATTR_BIT_MAP_COUNT, 0};
if (getattrlist(path, &al, attrbuf, sizeof(attrbuf), FSOPT_NOFOLLOW) == 0) {
@@ -540,7 +541,7 @@ dir_initialize(int argc, VALUE *argv, VALUE dir)
#endif
if (dp->dir == NULL) {
RB_GC_GUARD(dirname);
- rb_sys_fail_path(orig);
+ rb_syserr_fail_path(e, orig);
}
}
dp->path = orig;
@@ -752,7 +753,8 @@ dir_read(VALUE dir)
return rb_external_str_new_with_enc(dp->d_name, NAMLEN(dp), dirp->enc);
}
else {
- if (errno != 0) rb_sys_fail(0);
+ int e = errno;
+ if (e != 0) rb_syserr_fail(e, 0);
return Qnil; /* end of stream */
}
}