public Method

Stat.readable?

stat.readable?     true or false

Returns true if stat is readable by the effective user id of this process.

File.stat("testfile").readable?   #=> true

Source Code

/*
*  call-seq:
*     stat.readable?    => true or false
*  
*  Returns <code>true</code> if <i>stat</i> is readable by the
*  effective user id of this process.
*     
*     File.stat("testfile").readable?   #=> true
*     
*/

static VALUE
rb_stat_r(obj)
   VALUE obj;
{
   struct stat *st = get_stat(obj);

#ifdef USE_GETEUID
   if (geteuid() == 0) return Qtrue;
#endif
#ifdef S_IRUSR
   if (rb_stat_owned(obj))
       return st->st_mode & S_IRUSR ? Qtrue : Qfalse;
#endif
#ifdef S_IRGRP
   if (rb_stat_grpowned(obj))
       return st->st_mode & S_IRGRP ? Qtrue : Qfalse;
#endif
#ifdef S_IROTH
   if (!(st->st_mode & S_IROTH)) return Qfalse;
#endif
   return Qtrue;
}
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.