Method: File.file?

Defined in:
file.c

.file?(file) ⇒ Boolean

Returns true if the named file exists and is a regular file.

file can be an IO object.

If the file argument is a symbolic link, it will resolve the symbolic link and use the file referenced by the link.

Returns:

  • (Boolean)


1983
1984
1985
1986
1987
1988
1989
1990
1991
# File 'file.c', line 1983

static VALUE
rb_file_file_p(VALUE obj, VALUE fname)
{
    struct stat st;

    if (rb_stat(fname, &st) < 0) return Qfalse;
    if (S_ISREG(st.st_mode)) return Qtrue;
    return Qfalse;
}