writable?()
public
Returns true if stat is writable by the effective user id of this
process.
File.stat("testfile").writable?
Show source
/*
* call-seq:
* stat.writable? -> true or false
*
* Returns <code>true</code> if <i>stat</i> is writable by the
* effective user id of this process.
*
* File.stat("testfile").writable? #=> true
*
*/
static VALUE
rb_stat_w(obj)
VALUE obj;
{
struct stat *st = get_stat(obj);
if (geteuid() == 0) return Qtrue;
if (rb_stat_owned(obj))
return st->st_mode & S_IWUSR ? Qtrue : Qfalse;
if (rb_stat_grpowned(obj))
return st->st_mode & S_IWGRP ? Qtrue : Qfalse;
if (!(st->st_mode & S_IWOTH)) return Qfalse;
return Qtrue;
}