Method: File.exist?

Defined in:
file.c

.exist?(file_name) ⇒ Boolean

Return true if the named file exists.

file_name can be an IO object.

“file exists” means that stat() or fstat() system call is successful.

Returns:

  • (Boolean)


1752
1753
1754
1755
1756
1757
1758
1759
# File 'file.c', line 1752

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

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