class FakeFS::File::Stat
Attributes
atime[R]
birthtime[R]
ctime[R]
gid[R]
mode[R]
mtime[R]
uid[R]
Public Class Methods
new(file, lstat = false)
click to toggle source
# File lib/fakefs/file.rb, line 322 def initialize(file, lstat = false) fail(Errno::ENOENT, file) unless File.exist?(file) @file = file @fake_file = FileSystem.find(@file) @__lstat = lstat @ctime = @fake_file.ctime @mtime = @fake_file.mtime @atime = @fake_file.atime @mode = @fake_file.mode @uid = @fake_file.uid @gid = @fake_file.gid @birthtime = if @fake_file.respond_to?(:birthtime) @fake_file.birthtime else @fake_file.ctime end end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/fakefs/file.rb, line 402 def <=>(other) @mtime <=> other.mtime end
directory?()
click to toggle source
# File lib/fakefs/file.rb, line 346 def directory? File.directory?(@file) end
file?()
click to toggle source
# File lib/fakefs/file.rb, line 350 def file? File.file?(@file) end
ftype()
click to toggle source
# File lib/fakefs/file.rb, line 354 def ftype return 'link' if symlink? return 'directory' if directory? 'file' end
nlink()
click to toggle source
# File lib/fakefs/file.rb, line 384 def nlink @fake_file.links.size end
readable?()
click to toggle source
assumes, like above, that all files are readable and writable.
# File lib/fakefs/file.rb, line 361 def readable? true end
size()
click to toggle source
# File lib/fakefs/file.rb, line 388 def size if @__lstat && symlink? @fake_file.target.size else File.size(@file) end end
sticky?()
click to toggle source
Assume nothing is sticky.
# File lib/fakefs/file.rb, line 370 def sticky? false end
symlink?()
click to toggle source
# File lib/fakefs/file.rb, line 342 def symlink? File.symlink?(@file) end
world_readable?()
click to toggle source
# File lib/fakefs/file.rb, line 380 def world_readable? 0777 end
world_writable?()
click to toggle source
World_writable and readable are platform dependent usually comparing with S_IROTH defined on compilation (MRI)
# File lib/fakefs/file.rb, line 376 def world_writable? 0777 end
writable?()
click to toggle source
# File lib/fakefs/file.rb, line 365 def writable? true end
zero?()
click to toggle source
# File lib/fakefs/file.rb, line 396 def zero? size == 0 end