class FakeFS::File::Stat

Attributes

atime[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 258
def initialize(file, __lstat = false)
  if !File.exists?(file)
    raise(Errno::ENOENT, "No such file or directory - #{file}")
  end

  @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
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/fakefs/file.rb, line 308
def <=>(other)
  @mtime <=> other.mtime
end
directory?() click to toggle source
# File lib/fakefs/file.rb, line 278
def directory?
  File.directory?(@file)
end
readable?() click to toggle source

assumes, like above, that all files are readable and writable

# File lib/fakefs/file.rb, line 283
def readable?
  true
end
size() click to toggle source
# File lib/fakefs/file.rb, line 294
def size
  if @__lstat && symlink?
    @fake_file.target.size
  else
    File.size(@file)
  end
end
writable?() click to toggle source
# File lib/fakefs/file.rb, line 286
def writable?
  true
end
zero?() click to toggle source
# File lib/fakefs/file.rb, line 302
def zero?
  size == 0
end