Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

File::Stat#owned?

() -> bool
owned? → true or false

Returns whether self represents a filesystem entry that, at the time self was created, existed and was owned by the user of the current process; see Snapshot:

Example
filepath = 'doc/t.tmp'
File.write(filepath, 'foo')
filestat = File.stat(filepath)
filestat.owned?          # => true
File.delete(filepath)
filestat.owned?          # => true  # Snapshot unchanged.
dirpath = 'doc/tmp'
Dir.mkdir(dirpath)
dirstat = File.stat(dirpath)
dirstat.owned?           # => true
Dir.rmdir(dirpath)
dirstat.owned?           # => true  # Snapshot unchanged.
File.stat('/etc').owned? # => false
See also #nlink #pipe? #mtime #rdev also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0