Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
FileTest#setgid?
(::path | ::io file_name) -> bool
File.setgid?(object) → true or false
file.c
View on GitHub ↗
static VALUE
rb_file_sgid_p(VALUE obj, VALUE fname)
{
#ifdef S_ISGID
return check3rdbyte(fname, S_ISGID);
#else
return Qfalse;
#endif
}
Returns whether the setgid bit is set in the special bits for the given object, which may be a path or an IO object:
Example
path = '/tmp/t.tmp' File.write(path, 'foo') mode = File.stat(path).mode.to_s(8) # => "100664" File.setgid?(path) # => false File.chmod(0o2644, path) # Set the bit. mode = File.stat(path).mode.to_s(8) # => "102644" File.setgid?(path) # => true File.delete(path) # Clean up. File.setgid?($stdin) # => false
On Windows, the bit is never set; the method always returns false.