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 287
def initialize(file, __lstat = false)
  if !File.exists?(file)
    raise Errno::ENOENT, 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 348
def <=>(other)
  @mtime <=> other.mtime
end
directory?() click to toggle source
# File lib/fakefs/file.rb, line 307
def directory?
  File.directory?(@file)
end
file?() click to toggle source
# File lib/fakefs/file.rb, line 311
def file?
  File.file?(@file)
end
ftype() click to toggle source
# File lib/fakefs/file.rb, line 315
def ftype
  return 'link' if symlink?
  return 'directory' if directory?
  return 'file'
end
readable?() click to toggle source

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

# File lib/fakefs/file.rb, line 322
def readable?
  true
end
size() click to toggle source
# File lib/fakefs/file.rb, line 334
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 326
def writable?
  true
end
zero?() click to toggle source
# File lib/fakefs/file.rb, line 342
def zero?
  size == 0
end