Method: File.size?

Defined in:
file.c

.size?(file_name) ⇒ Integer?

Returns nil if file_name doesn’t exist or has zero size, the size of the file otherwise.

file_name can be an IO object.

Returns:



2023
2024
2025
2026
2027
2028
2029
2030
2031
# File 'file.c', line 2023

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

    if (rb_stat(fname, &st) < 0) return Qnil;
    if (st.st_size == 0) return Qnil;
    return OFFT2NUM(st.st_size);
}