Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
File::Stat#sticky?
() -> bool
sticky? → true or false
file.c
View on GitHub ↗
static VALUE
rb_stat_sticky(VALUE obj)
{
#ifdef S_ISVTX
if (get_stat(obj)->ST_(mode) & S_ISVTX) return Qtrue;
#endif
return Qfalse;
}
Returns whether the sticky bit is set in the special bits for self:
Example
filepath = '/tmp/t.tmp' File.write(filepath, 'foo') stat = File.stat(filepath) stat.sticky? # => false stat.mode.to_s(8) # => "100664" File.chmod(01644, filepath) # => 1 # Stat unchanged. stat.sticky? # => false stat.mode.to_s(8) # => "100664" stat = File.stat(filepath) # Fresh stat. stat.sticky? # => true stat.mode.to_s(8) # => "101644" File.delete(filepath) # Clean up.
Returns false on Windows.