Class: Fat32::FileObject

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

Overview

Top level file object.

Constant Summary

Constants included from Fat32

ATTRIB_OFFSET, BOOT_SECT, CHARS_PER_LFN, DEF_CACHE_SIZE, DIR_ENT_LFN, DIR_ENT_SFN, DIR_ENT_SIZE, DOS_SIGNATURE, FSINFO, FSINFO_SIG1, FSINFO_SIG2, FSINFO_SIG3, LFN_NAME_MAXLEN, SIZEOF_BOOT_SECT, SIZEOF_FSINFO

Instance Attribute Summary collapse

Attributes included from Fat32

#boot_sector, #cache_hits, #dir_cache, #drive_root, #rootDirEnt

Instance Method Summary collapse

Methods included from Fat32

#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_getFile, #ifs_putFile, #unnormalizePath

Constructor Details

#initialize(path, miqfs) ⇒ FileObject

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



25
26
27
28
29
# File 'lib/fs/MiqFS/modules/Fat32.rb', line 25

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

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



21
22
23
# File 'lib/fs/MiqFS/modules/Fat32.rb', line 21

def data
  @data
end

#deObject (readonly)

Returns the value of attribute de.



21
22
23
# File 'lib/fs/MiqFS/modules/Fat32.rb', line 21

def de
  @de
end

#dirtyObject (readonly)

Returns the value of attribute dirty.



21
22
23
# File 'lib/fs/MiqFS/modules/Fat32.rb', line 21

def dirty
  @dirty
end

#miqfsObject (readonly)

Returns the value of attribute miqfs.



21
22
23
# File 'lib/fs/MiqFS/modules/Fat32.rb', line 21

def miqfs
  @miqfs
end

#parentDirClusterObject (readonly)

Returns the value of attribute parentDirCluster.



21
22
23
# File 'lib/fs/MiqFS/modules/Fat32.rb', line 21

def parentDirCluster
  @parentDirCluster
end

#pathObject (readonly)

Returns the value of attribute path.



21
22
23
# File 'lib/fs/MiqFS/modules/Fat32.rb', line 21

def path
  @path
end

Instance Method Details

#open(mode = "r") ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fs/MiqFS/modules/Fat32.rb', line 31

def open(mode = "r")
  # Fat32 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?
    @data = FileData.new(@de, @miqfs.boot_sector)
  end
  if mode.include?("w")
    @de.delete(@miqfs.boot_sector) unless @de.nil?
    @de, @parentDirCluster = ifs_putFile(@path, @miqfs)
    @data = FileData.new(@de, @miqfs.boot_sector)
  end
  if mode.include?("a")
    @de, @parentDirCluster = ifs_putFile(@path, @miqfs) if @de.nil?
    @data = FileData.new(@de, @miqfs.boot_sector) if @data.nil?
    @data.read
  end
end