Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
File.world_writable?
(::string | ::_ToPath | ::IO file_name) -> ::Integer?
File.world_writable?(file_name) → integer or nil
file.c
View on GitHub ↗
static VALUE
rb_file_world_writable_p(VALUE obj, VALUE fname)
{
#ifdef S_IWOTH
struct stat st;
if (rb_stat(fname, &st) < 0) return Qnil;
if ((st.st_mode & (S_IWOTH)) == S_IWOTH) {
return UINT2NUM(st.st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
}
#endif
return Qnil;
}
If file_name is writable by others, returns an integer representing the file permission bits of file_name. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2).
file_name can be an IO object.
Example
File.world_writable?("/tmp") #=> 511 m = File.world_writable?("/tmp") sprintf("%o", m) #=> "777"
See also
.world_readable?
.writable?
.utime
.writable_real?
also in
4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0