Methods
A
B
C
D
E
F
I
J
L
M
N
R
S
T
W
Classes and Modules
Constants
PATH_SEPARATOR = '/'
MODES = [ READ_ONLY = "r", READ_WRITE = "r+", WRITE_ONLY = "w", READ_WRITE_TRUNCATE = "w+", APPEND_WRITE_ONLY = "a", APPEND_READ_WRITE = "a+" ]
FILE_CREATION_MODES = MODES - [READ_ONLY, READ_WRITE]
MODE_BITMASK = RealFile::RDONLY | RealFile::WRONLY | RealFile::RDWR | RealFile::APPEND | RealFile::CREAT | RealFile::EXCL | RealFile::NONBLOCK | RealFile::TRUNC | RealFile::NOCTTY | RealFile::SYNC
FILE_CREATION_BITMASK = RealFile::CREAT
Attributes
[R] path
Class Public methods
basename(*args)
# File lib/fakefs/file.rb, line 113
    def self.basename(*args)
      RealFile.basename(*args)
    end
const_missing(name)
# File lib/fakefs/file.rb, line 79
    def self.const_missing(name)
      RealFile.const_get(name)
    end
ctime(path)
# File lib/fakefs/file.rb, line 59
    def self.ctime(path)
      if exists?(path)
        FileSystem.find(path).ctime
      else
        raise Errno::ENOENT
      end
    end
delete(file_name, *additional_file_names)
# File lib/fakefs/file.rb, line 159
    def self.delete(file_name, *additional_file_names)
      if !exists?(file_name)
        raise Errno::ENOENT, "No such file or directory - #{file_name}"
      end

      FileUtils.rm(file_name)

      additional_file_names.each do |file_name|
        FileUtils.rm(file_name)
      end

      additional_file_names.size + 1
    end
directory?(path)
# File lib/fakefs/file.rb, line 83
    def self.directory?(path)
      if path.respond_to? :entry
        path.entry.is_a? FakeDir
      else
        result = FileSystem.find(path)
        result ? result.entry.is_a?(FakeDir) : false
      end
    end
dirname(path)
# File lib/fakefs/file.rb, line 117
    def self.dirname(path)
      RealFile.dirname(path)
    end
exist?(path)
# File lib/fakefs/file.rb, line 39
    def self.exist?(path)
      !!FileSystem.find(path)
    end
expand_path(*args)
# File lib/fakefs/file.rb, line 109
    def self.expand_path(*args)
      RealFile.expand_path(*args)
    end
extname(path)
# File lib/fakefs/file.rb, line 31
    def self.extname(path)
      RealFile.extname(path)
    end
file?(path)
# File lib/fakefs/file.rb, line 100
    def self.file?(path)
      if path.respond_to? :entry
        path.entry.is_a? FakeFile
      else
        result = FileSystem.find(path)
        result ? result.entry.is_a?(FakeFile) : false
      end
    end
join(*parts)
# File lib/fakefs/file.rb, line 35
    def self.join(*parts)
      parts * PATH_SEPARATOR
    end
link(source, dest)
# File lib/fakefs/file.rb, line 139
    def self.link(source, dest)
      if directory?(source)
        raise Errno::EPERM, "Operation not permitted - #{source} or #{dest}"
      end

      if !exists?(source)
        raise Errno::ENOENT, "No such file or directory - #{source} or #{dest}"
      end

      if exists?(dest)
        raise Errno::EEXIST, "File exists - #{source} or #{dest}"
      end

      source = FileSystem.find(source)
      dest = FileSystem.add(dest, source.entry.clone)
      source.link(dest)

      0
    end
lstat(file)
# File lib/fakefs/file.rb, line 185
    def self.lstat(file)
      File::Stat.new(file, true)
    end
mtime(path)
# File lib/fakefs/file.rb, line 51
    def self.mtime(path)
      if exists?(path)
        FileSystem.find(path).mtime
      else
        raise Errno::ENOENT
      end
    end
new(path, mode = READ_ONLY, perm = nil)
# File lib/fakefs/file.rb, line 227
    def initialize(path, mode = READ_ONLY, perm = nil)
      @path = path
      @mode = mode
      @file = FileSystem.find(path)
      @autoclose = true

      check_modes!

      file_creation_mode? ? create_missing_file : check_file_existence!

      super(@file.content, mode)
    end
read(path)
# File lib/fakefs/file.rb, line 126
    def self.read(path)
      file = new(path)
      if file.exists?
        file.read
      else
        raise Errno::ENOENT
      end
    end
readlines(path)
# File lib/fakefs/file.rb, line 135
    def self.readlines(path)
      read(path).split("\n")
    end
readlink(path)
# File lib/fakefs/file.rb, line 121
    def self.readlink(path)
      symlink = FileSystem.find(path)
      FileSystem.find(symlink.target).to_s
    end
size(path)
# File lib/fakefs/file.rb, line 67
    def self.size(path)
      read(path).length
    end
size?(path)
# File lib/fakefs/file.rb, line 71
    def self.size?(path)
      if exists?(path) && !size(path).zero?
        true
      else
        nil
      end
    end
stat(file)
# File lib/fakefs/file.rb, line 181
    def self.stat(file)
      File::Stat.new(file)
    end
symlink(source, dest)
# File lib/fakefs/file.rb, line 177
    def self.symlink(source, dest)
      FileUtils.ln_s(source, dest)
    end
symlink?(path)
# File lib/fakefs/file.rb, line 92
    def self.symlink?(path)
      if path.respond_to? :entry
        path.is_a? FakeSymlink
      else
        FileSystem.find(path).is_a? FakeSymlink
      end
    end
Instance Public methods
atime()
# File lib/fakefs/file.rb, line 290
    def atime
      raise NotImplementedError
    end
autoclose?()
# File lib/fakefs/file.rb, line 335
      def autoclose?
        @autoclose
      end
binmode?()
# File lib/fakefs/file.rb, line 315
      def binmode?
        raise NotImplementedError
      end
chmod(mode_int)
# File lib/fakefs/file.rb, line 294
    def chmod(mode_int)
      raise NotImplementedError
    end
chown(owner_int, group_int)
# File lib/fakefs/file.rb, line 298
    def chown(owner_int, group_int)
      raise NotImplementedError
    end
close_on_exec=(bool)
# File lib/fakefs/file.rb, line 319
      def close_on_exec=(bool)
        raise NotImplementedError
      end
close_on_exec?()
# File lib/fakefs/file.rb, line 323
      def close_on_exec?
        raise NotImplementedError
      end
ctime()
# File lib/fakefs/file.rb, line 302
    def ctime
      self.class.ctime(@path)
    end
exists?()
# File lib/fakefs/file.rb, line 240
    def exists?
      true
    end
flock(locking_constant)
# File lib/fakefs/file.rb, line 306
    def flock(locking_constant)
      raise NotImplementedError
    end
ioctl(integer_cmd, arg)
# File lib/fakefs/file.rb, line 255
    def ioctl(integer_cmd, arg)
      raise NotImplementedError
    end
lstat()
# File lib/fakefs/file.rb, line 267
    def lstat
      self.class.lstat(@path)
    end
mtime()
# File lib/fakefs/file.rb, line 310
    def mtime
      self.class.mtime(@path)
    end
read_nonblock(maxlen, outbuf = nil)
# File lib/fakefs/file.rb, line 259
    def read_nonblock(maxlen, outbuf = nil)
      raise NotImplementedError
    end
readpartial(maxlen, outbuf = nil)
# File lib/fakefs/file.rb, line 286
    def readpartial(maxlen, outbuf = nil)
      raise NotImplementedError
    end
size()
# File lib/fakefs/file.rb, line 341
      def size
        File.size(@path)
      end
stat()
# File lib/fakefs/file.rb, line 263
    def stat
      self.class.stat(@path)
    end
sysseek(position, whence = SEEK_SET)
# File lib/fakefs/file.rb, line 271
    def sysseek(position, whence = SEEK_SET)
      seek(position, whence)
      pos
    end
to_io()
# File lib/fakefs/file.rb, line 278
    def to_io
      self
    end
to_path()
# File lib/fakefs/file.rb, line 327
      def to_path
        raise NotImplementedError
      end
write_nonblock(string)
# File lib/fakefs/file.rb, line 282
    def write_nonblock(string)
      raise NotImplementedError
    end