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
static VALUE
rb_stat_x(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;
}