Method: File::Stat#readable?
- Defined in:
- file.c
#readable? ⇒ Boolean
Returns true if stat is readable by the effective user id of this process.
File.stat("testfile").readable? #=> true
5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 |
# File 'file.c', line 5929 static VALUE rb_stat_r(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 RBOOL(st->st_mode & S_IRUSR); #endif #ifdef S_IRGRP if (rb_stat_grpowned(obj)) return RBOOL(st->st_mode & S_IRGRP); #endif #ifdef S_IROTH if (!(st->st_mode & S_IROTH)) return Qfalse; #endif return Qtrue; } |