Class: Ext3::FileObject

Inherits:
Object
  • Object
show all
Includes:
Ext3
Defined in:
lib/fs/MiqFS/modules/Ext3.rb

Overview

Top level file object.

Constant Summary

Constants included from Ext3

DEF_CACHE_SIZE, DIR_ENTRY_NEW, DIR_ENTRY_ORIGINAL, EX_ATTRIB_HEADER, EX_ATTRIB_NAME, GDE, GDE_SIZE, HASH_TREE_ENTRY_FIRST, HASH_TREE_ENTRY_NEXT, HASH_TREE_HEADER, INODE, INODE_SIZE, POSIX_ACL_ENTRY, POSIX_ACL_HEADER, SIZEOF_DIR_ENTRY_NEW, SIZEOF_DIR_ENTRY_ORIGINAL, SIZEOF_GDE, SUPERBLOCK, SUPERBLOCK_OFFSET, SUPERBLOCK_SIG, SUPERBLOCK_SIZE, SUPERBLOCK_VALIDATE, SUPERBLOCK_VALIDATE_SIZE, SYM_LNK_OFFSET, SYM_LNK_SIZE

Instance Attribute Summary collapse

Attributes included from Ext3

#cache_hits, #dir_cache, #entry_cache, #rootDir, #superblock

Instance Method Summary collapse

Methods included from Ext3

#fs_dirEntries, #fs_dirMkdir, #fs_dirRmdir, #fs_fileAtime, #fs_fileAtime_obj, #fs_fileClose, #fs_fileCtime, #fs_fileCtime_obj, #fs_fileDelete, #fs_fileDirectory?, #fs_fileExists?, #fs_fileFile?, #fs_fileMtime, #fs_fileMtime_obj, #fs_fileOpen, #fs_fileRead, #fs_fileSeek, #fs_fileSize, #fs_fileSize_obj, #fs_fileWrite, #fs_freeBytes, #fs_init, #fs_isSymLink?, #ifs_getDir, #ifs_getDirR, #ifs_getFile, #ifs_putFile, #unnormalizePath

Constructor Details

#initialize(path, miqfs) ⇒ FileObject

fs_fileOpen passes ‘self’ into .. er, ‘this’.



24
25
26
27
# File 'lib/fs/MiqFS/modules/Ext3.rb', line 24

def initialize(path, miqfs)
  @path = path
  @miqfs = miqfs
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



20
21
22
# File 'lib/fs/MiqFS/modules/Ext3.rb', line 20

def data
  @data
end

#deObject (readonly)

Returns the value of attribute de.



20
21
22
# File 'lib/fs/MiqFS/modules/Ext3.rb', line 20

def de
  @de
end

#inodeObject (readonly)

Returns the value of attribute inode.



20
21
22
# File 'lib/fs/MiqFS/modules/Ext3.rb', line 20

def inode
  @inode
end

#miqfsObject (readonly)

Returns the value of attribute miqfs.



20
21
22
# File 'lib/fs/MiqFS/modules/Ext3.rb', line 20

def miqfs
  @miqfs
end

#pathObject (readonly)

Returns the value of attribute path.



20
21
22
# File 'lib/fs/MiqFS/modules/Ext3.rb', line 20

def path
  @path
end

Instance Method Details

#open(mode = "r") ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fs/MiqFS/modules/Ext3.rb', line 29

def open(mode = "r")
  # Ext3 module methods use miqfs instance accessors to touch @boot_sector.
  @mode = mode.downcase
  @de = ifs_getFile(@path, @miqfs)
  unless @de.nil?
    raise "File is directory: '#{@path}'" if @de.isDir?
  end
  if mode.include?("r")
    raise "File not found: '#{@path}'" if @de.nil?
    @inode = @miqfs.superblock.getInode(@de.inode)
    @data = FileData.new(@inode, @miqfs.superblock)
  end
end