Method: File::Stat#size?

Defined in:
file.c

#size?Integer?

Returns nil if stat is a zero-length file, the size of the file otherwise.

File.stat("testfile").size?   #=> 66
File.stat(File::NULL).size?   #=> nil

Returns:



6217
6218
6219
6220
6221
6222
6223
6224
# File 'file.c', line 6217

static VALUE
rb_stat_s(VALUE obj)
{
    rb_off_t size = get_stat(obj)->st_size;

    if (size == 0) return Qnil;
    return OFFT2NUM(size);
}