End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
File.exist?
File.exist?(file_name) → true or false
file.c
View on GitHub ↗
static VALUE
rb_file_exist_p(VALUE obj, VALUE fname)
{
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
return Qtrue;
}
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.
See also
.executable_real?
.expand_path
.executable?
.extname
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1