Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
File.file?
(::string | ::_ToPath | ::IO file) -> bool
File.file?(file) → true or false
file.c
View on GitHub ↗
static VALUE
rb_file_file_p(VALUE obj, VALUE fname)
{
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
return RBOOL(S_ISREG(st.st_mode));
}
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.