Method: File.executable?

Defined in:
file.c

.executable?(file_name) ⇒ Boolean

Returns true if the named file is executable by the effective user and group id of this process. See eaccess(3).

Windows does not support execute permissions separately from read permissions. On Windows, a file is only considered executable if it ends in .bat, .cmd, .com, or .exe.

Note that some OS-level security features may cause this to return true even though the file is not executable by the effective user/group.

Returns:

  • (Boolean)


1938
1939
1940
1941
1942
1943
# File 'file.c', line 1938

static VALUE
rb_file_executable_p(VALUE obj, VALUE fname)
{
    if (rb_eaccess(fname, X_OK) < 0) return Qfalse;
    return Qtrue;
}