Methods
#
C
D
E
F
G
M
N
O
P
R
S
T
Included Modules
Class Public methods
[](pattern)
# File lib/fakefs/dir.rb, line 55
    def self.[](pattern)
      glob(pattern)
    end
chdir(dir, &blk)
# File lib/fakefs/dir.rb, line 59
    def self.chdir(dir, &blk)
      FileSystem.chdir(dir, &blk)
    end
chroot(string)
# File lib/fakefs/dir.rb, line 63
    def self.chroot(string)
      # Not implemented yet
    end
delete(string)
# File lib/fakefs/dir.rb, line 67
    def self.delete(string)
      raise SystemCallError, "No such file or directory - #{string}" unless FileSystem.find(string).values.empty?
      FileSystem.delete(string)
    end
entries(dirname)
# File lib/fakefs/dir.rb, line 72
    def self.entries(dirname)
      raise SystemCallError, dirname unless FileSystem.find(dirname)
      Dir.new(dirname).map { |file| File.basename(file) }
    end
foreach(dirname, &block)
# File lib/fakefs/dir.rb, line 77
    def self.foreach(dirname, &block)
      Dir.open(dirname) { |file| yield file }
    end
glob(pattern)
# File lib/fakefs/dir.rb, line 81
    def self.glob(pattern)
      [FileSystem.find(pattern) || []].flatten.map{|e| e.to_s}.sort
    end
mkdir(string, integer = 0)
# File lib/fakefs/dir.rb, line 85
    def self.mkdir(string, integer = 0)
      parent = string.split('/')
      parent.pop
      raise Errno::ENOENT, "No such file or directory - #{string}" unless parent.join == "" || FileSystem.find(parent.join('/'))
      raise Errno::EEXIST, "File exists - #{string}" if File.exists?(string)
      FileUtils.mkdir_p(string)
    end
new(string)
# File lib/fakefs/dir.rb, line 5
    def initialize(string)
      raise Errno::ENOENT, string unless FileSystem.find(string)
      @path = string
      @open = true
      @pointer = 0
      @contents = [ '.', '..', ] + FileSystem.find(@path).values
    end
open(string, &block)
# File lib/fakefs/dir.rb, line 93
    def self.open(string, &block)
      if block_given?
        Dir.new(string).each { |file| yield(file) }
      else
        Dir.new(string)
      end
    end
pwd()
# File lib/fakefs/dir.rb, line 105
    def self.pwd
      FileSystem.current_dir.to_s
    end
tmpdir()
# File lib/fakefs/dir.rb, line 101
    def self.tmpdir
      '/tmp'
    end
Instance Public methods
close()
# File lib/fakefs/dir.rb, line 13
    def close
      @open = false
      @pointer = nil
      @contents = nil
      nil
    end
each(&block)
# File lib/fakefs/dir.rb, line 20
    def each(&block)
      while f = read
        yield f
      end
    end
path()
# File lib/fakefs/dir.rb, line 26
    def path
      @path
    end
pos()
# File lib/fakefs/dir.rb, line 30
    def pos
      @pointer
    end
pos=(integer)
# File lib/fakefs/dir.rb, line 34
    def pos=(integer)
      @pointer = integer
    end
read()
# File lib/fakefs/dir.rb, line 38
    def read
      raise IOError, "closed directory" if @pointer == nil
      n = @contents[@pointer]
      @pointer += 1
      n.to_s.gsub(path + '/', '') if n
    end
rewind()
# File lib/fakefs/dir.rb, line 45
    def rewind
      @pointer = 0
    end
seek(integer)
# File lib/fakefs/dir.rb, line 49
    def seek(integer)
      raise IOError, "closed directory" if @pointer == nil
      @pointer = integer
      @contents[integer]
    end