Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
File::Stat#setgid?
() -> bool
setgid? → true or false
file.c
View on GitHub ↗
static VALUE
rb_stat_sgid(VALUE obj)
{
#ifdef S_ISGID
if (get_stat(obj)->ST_(mode) & S_ISGID) return Qtrue;
#endif
return Qfalse;
}
Returns whether the setgid bit is set in the special bits for the entry represented in self:
Example
path = '/tmp/t.tmp' File.write(path, 'foo') stat = File.stat(path) # Take a snapshot. stat.setgid? # => false stat.mode.to_s(8) # => "100664" File.chmod(0o2644, path) # Set the bit; stat snapshot unchanged. stat.setgid? # => false stat.mode.to_s(8) # => "100664" stat = File.stat(path) # Fresh stat; snapshot changed. stat.setgid? # => true stat.mode.to_s(8) # => "102644" File.delete(path) # Clean up.
On Windows, the bit is never set; the method always returns false.