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