static public Method

Stat.new(p1)

File::Stat.new(file_name) => stat

Create a File::Stat object for the given file name (raising an exception if the file doesn’t exist).

Source Code

/*
* call-seq:
*
*   File::Stat.new(file_name)  => stat
*
* Create a File::Stat object for the given file name (raising an
* exception if the file doesn't exist).
*/

static VALUE
rb_stat_init(obj, fname)
   VALUE obj, fname;
{
   struct stat st, *nst;

   SafeStringValue(fname);

   if (stat(StringValueCStr(fname), &st) == -1) {
       rb_sys_fail(RSTRING(fname)->ptr);
   }
   if (DATA_PTR(obj)) {
       free(DATA_PTR(obj));
       DATA_PTR(obj) = NULL;
   }
   nst = ALLOC(struct stat);
   *nst = st;
   DATA_PTR(obj) = nst;

   return Qnil;
}
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.