/* * call-seq: * stat.writable_real? -> true or false * * Returns <code>true</code> if <i>stat</i> is writable by the real * user id of this process. * * File.stat("testfile").writable_real? #=> true * */ static VALUE rb_stat_W(obj) VALUE obj; { struct stat *st = get_stat(obj); #ifdef USE_GETEUID if (getuid() == 0) return Qtrue; #endif #ifdef S_IWUSR if (rb_stat_rowned(obj)) return st->st_mode & S_IWUSR ? Qtrue : Qfalse; #endif #ifdef S_IWGRP if (group_member(get_stat(obj)->st_gid)) return st->st_mode & S_IWGRP ? Qtrue : Qfalse; #endif #ifdef S_IWOTH if (!(st->st_mode & S_IWOTH)) return Qfalse; #endif return Qtrue; }