Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
File.empty?
(::string | ::_ToPath | ::IO file_name) -> bool
File.zero?(file_name) → true or false
file.c
View on GitHub ↗
static VALUE
rb_file_zero_p(VALUE obj, VALUE fname)
{
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
return RBOOL(st.st_size == 0);
}
Returns true if the named file exists and has a zero size.
file_name can be an IO object.
See also
.dirname
.executable?
.directory?
.executable_real?
also in
4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0