executable?()
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? #=> false
static VALUE rb_stat_x(VALUE obj) { struct stat *st = get_stat(obj); #ifdef USE_GETEUID if (geteuid() == 0) { return st->st_mode & S_IXUGO ? Qtrue : Qfalse; } #endif #ifdef S_IXUSR if (rb_stat_owned(obj)) return st->st_mode & S_IXUSR ? Qtrue : Qfalse; #endif #ifdef S_IXGRP if (rb_stat_grpowned(obj)) return st->st_mode & S_IXGRP ? Qtrue : Qfalse; #endif #ifdef S_IXOTH if (!(st->st_mode & S_IXOTH)) return Qfalse; #endif return Qtrue; }