mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add RBOOL macro and use it
This commit is contained in:
parent
656b49ec47
commit
64adeeadaa
Notes:
git
2021-07-29 12:51:36 +09:00
Merged: https://github.com/ruby/ruby/pull/4677 Merged-By: nobu <nobu@ruby-lang.org>
1 changed files with 8 additions and 12 deletions
20
file.c
20
file.c
|
@ -171,6 +171,8 @@ int flock(int, int);
|
|||
#include "ruby/thread.h"
|
||||
#include "ruby/util.h"
|
||||
|
||||
#define RBOOL(v) ((v) ? Qtrue : Qfalse)
|
||||
|
||||
VALUE rb_cFile;
|
||||
VALUE rb_mFileTest;
|
||||
VALUE rb_cStat;
|
||||
|
@ -1830,8 +1832,7 @@ rb_file_exists_p(VALUE obj, VALUE fname)
|
|||
static VALUE
|
||||
rb_file_readable_p(VALUE obj, VALUE fname)
|
||||
{
|
||||
if (rb_eaccess(fname, R_OK) < 0) return Qfalse;
|
||||
return Qtrue;
|
||||
return RBOOL(rb_eaccess(fname, R_OK) >= 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1848,8 +1849,7 @@ rb_file_readable_p(VALUE obj, VALUE fname)
|
|||
static VALUE
|
||||
rb_file_readable_real_p(VALUE obj, VALUE fname)
|
||||
{
|
||||
if (rb_access(fname, R_OK) < 0) return Qfalse;
|
||||
return Qtrue;
|
||||
return RBOOL(rb_access(fname, R_OK) >= 0);
|
||||
}
|
||||
|
||||
#ifndef S_IRUGO
|
||||
|
@ -1904,8 +1904,7 @@ rb_file_world_readable_p(VALUE obj, VALUE fname)
|
|||
static VALUE
|
||||
rb_file_writable_p(VALUE obj, VALUE fname)
|
||||
{
|
||||
if (rb_eaccess(fname, W_OK) < 0) return Qfalse;
|
||||
return Qtrue;
|
||||
return RBOOL(rb_eaccess(fname, W_OK) >= 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1922,8 +1921,7 @@ rb_file_writable_p(VALUE obj, VALUE fname)
|
|||
static VALUE
|
||||
rb_file_writable_real_p(VALUE obj, VALUE fname)
|
||||
{
|
||||
if (rb_access(fname, W_OK) < 0) return Qfalse;
|
||||
return Qtrue;
|
||||
return RBOOL(rb_access(fname, W_OK) >= 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1974,8 +1972,7 @@ rb_file_world_writable_p(VALUE obj, VALUE fname)
|
|||
static VALUE
|
||||
rb_file_executable_p(VALUE obj, VALUE fname)
|
||||
{
|
||||
if (rb_eaccess(fname, X_OK) < 0) return Qfalse;
|
||||
return Qtrue;
|
||||
return RBOOL(rb_eaccess(fname, X_OK) >= 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1996,8 +1993,7 @@ rb_file_executable_p(VALUE obj, VALUE fname)
|
|||
static VALUE
|
||||
rb_file_executable_real_p(VALUE obj, VALUE fname)
|
||||
{
|
||||
if (rb_access(fname, X_OK) < 0) return Qfalse;
|
||||
return Qtrue;
|
||||
return RBOOL(rb_access(fname, X_OK) >= 0);
|
||||
}
|
||||
|
||||
#ifndef S_ISREG
|
||||
|
|
Loading…
Reference in a new issue