Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
File.grpowned?
(::path | ::IO file_name) -> bool
File.grpowned?(object) → true or false
file.c
View on GitHub ↗
static VALUE
rb_file_grpowned_p(VALUE obj, VALUE fname)
{
#ifndef _WIN32
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
if (rb_group_member(st.st_gid)) return Qtrue;
#endif
return Qfalse;
}
Returns false on Windows.
On other systems returns whether the effective group id of the calling process is the owner of the given object.
The given object may be the string path or an IO object:
Example
filepath = '/tmp/t.tmp' File.write(filepath, 'foo') File.grpowned?(filepath) # => true File.grpowned?('/etc') # => false File.grpowned?('/etc/passwd') # => false File.grpowned?($stdin) # => false File.grpowned?('nosuch') # => false File.delete(filepath) # Clean up.