public Method

IO.stat

ios.stat     stat

Returns status information for ios as an object of type File::Stat.

f = File.new("testfile")
s = f.stat
"%o" % s.mode   #=> "100644"
s.blksize       #=> 4096
s.atime         #=> Wed Apr 09 08:53:54 CDT 2003

Source Code

/*
*  call-seq:
*     ios.stat    => stat
*  
*  Returns status information for <em>ios</em> as an object of type
*  <code>File::Stat</code>.
*     
*     f = File.new("testfile")
*     s = f.stat
*     "%o" % s.mode   #=> "100644"
*     s.blksize       #=> 4096
*     s.atime         #=> Wed Apr 09 08:53:54 CDT 2003
*     
*/

static VALUE
rb_io_stat(obj)
   VALUE obj;
{
   OpenFile *fptr;
   struct stat st;

   GetOpenFile(obj, fptr);
   if (fstat(fileno(fptr->f), &st) == -1) {
       rb_sys_fail(fptr->path);
   }
   return stat_new(&st);
}
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.