static public Method

File.size?(p1)

File.size?(file_name)    Integer or nil

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

Source Code

/*
* call-seq:
*    File.size?(file_name)   => Integer or nil
*
* Returns +nil+ if +file_name+ doesn't exist or has zero size, the size of the
* file otherwise.
*/

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

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

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.