APIdock / Ruby
/
method

size

ruby latest stable - Class: File
size()
public

Returns the size of file in bytes.

File .new ("testfile").size  #=> 66
static VALUE
rb_file_size(VALUE obj)
{
 rb_io_t *fptr;
 struct stat st;
 GetOpenFile(obj, fptr);
 if (fptr->mode & FMODE_WRITABLE) {
 rb_io_flush_raw(obj, 0);
 }
 if (fstat(fptr->fd, &st) == -1) {
 rb_sys_fail_path(fptr->pathv);
 }
 return OFFT2NUM(st.st_size);
}

AltStyle によって変換されたページ (->オリジナル) /