# 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
# File lib/fakefs/file.rb, line 348 def <=>(other) @mtime <=> other.mtime end
# File lib/fakefs/file.rb, line 307 def directory? File.directory?(@file) end
# File lib/fakefs/file.rb, line 311 def file? File.file?(@file) end
# File lib/fakefs/file.rb, line 315 def ftype return 'link' if symlink? return 'directory' if directory? return 'file' end
# File lib/fakefs/file.rb, line 330 def nlink @fake_file.links.size end
assumes, like above, that all files are readable and writable
# File lib/fakefs/file.rb, line 322 def readable? true end
# File lib/fakefs/file.rb, line 334 def size if @__lstat && symlink? @fake_file.target.size else File.size(@file) end end
# File lib/fakefs/file.rb, line 303 def symlink? File.symlink?(@file) end
# File lib/fakefs/file.rb, line 326 def writable? true end
# File lib/fakefs/file.rb, line 342 def zero? size == 0 end