executable?()
public
Returns true if stat is executable or if the operating
system doesn’t distinguish executable files from nonexecutable files.
The tests are made using the effective owner of the process.
File.stat("testfile").executable?
Show source
/*
* call-seq:
* stat.executable? => true or false
*
* Returns <code>true</code> if <i>stat</i> is executable or if the
* operating system doesn't distinguish executable files from
* nonexecutable files. The tests are made using the effective owner of
* the process.
*
* File.stat("testfile").executable? #=> false
*
*/
static VALUE
rb_stat_x(obj)
VALUE obj;
{
struct stat *st = get_stat(obj);
if (geteuid() == 0) {
return st->st_mode & S_IXUGO ? Qtrue : Qfalse;
}
if (rb_stat_owned(obj))
return st->st_mode & S_IXUSR ? Qtrue : Qfalse;
if (rb_stat_grpowned(obj))
return st->st_mode & S_IXGRP ? Qtrue : Qfalse;
if (!(st->st_mode & S_IXOTH)) return Qfalse;
return Qtrue;
}