aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorS.H <gamelinks007@gmail.com>2021-09-15 08:11:05 +0900
committerGitHub <noreply@github.com>2021-09-15 08:11:05 +0900
commitb8c3a84bddac7366c4e391234b2535253869e885 (patch)
tree872dfa2014b75fc4c5dadb060900afa118cded71 /file.c
parent89242279e61b023a81c58065c62a82de8829d0b3 (diff)
downloadruby-b8c3a84bddac7366c4e391234b2535253869e885.tar.gz
Refactor and Using RBOOL macro
Diffstat (limited to 'file.c')
-rw-r--r--file.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/file.c b/file.c
index f5d01fda2a..98b9d50446 100644
--- a/file.c
+++ b/file.c
@@ -2019,8 +2019,7 @@ rb_file_file_p(VALUE obj, VALUE fname)
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
- if (S_ISREG(st.st_mode)) return Qtrue;
- return Qfalse;
+ return RBOOL(S_ISREG(st.st_mode));
}
/*
@@ -2039,8 +2038,7 @@ rb_file_zero_p(VALUE obj, VALUE fname)
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
- if (st.st_size == 0) return Qtrue;
- return Qfalse;
+ return RBOOL(st.st_size == 0);
}
/*
@@ -2080,8 +2078,7 @@ rb_file_owned_p(VALUE obj, VALUE fname)
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
- if (st.st_uid == geteuid()) return Qtrue;
- return Qfalse;
+ return RBOOL(st.st_uid == geteuid());
}
static VALUE
@@ -2090,8 +2087,7 @@ rb_file_rowned_p(VALUE obj, VALUE fname)
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
- if (st.st_uid == getuid()) return Qtrue;
- return Qfalse;
+ return RBOOL(st.st_uid == getuid());
}
/*
@@ -2124,8 +2120,7 @@ check3rdbyte(VALUE fname, int mode)
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
- if (st.st_mode & mode) return Qtrue;
- return Qfalse;
+ return RBOOL(st.st_mode & mode);
}
#endif