class Resilience::Image

Attributes

bytes_per_sector[RW]
file[RW]
object_table[RW]
object_tree[RW]
offset[RW]
opts[RW]
pages[RW]

all pages including shadow pages

root_dir[RW]
sectors_per_cluster[RW]
system_table[RW]

Public Class Methods

new(args={}) click to toggle source
# File lib/resilience/image.rb, line 28
def initialize(args={})
  @file         = args[:file] || []
end

Public Instance Methods

cluster_size() click to toggle source
# File lib/resilience/image.rb, line 16
def cluster_size
  @cluster_size ||= bytes_per_sector * sectors_per_cluster
end
parse() click to toggle source
# File lib/resilience/image.rb, line 32
def parse
  parse_bounds

  # each of these is a seperate parsing process,
  # though later ones may depend on former
  @pages        = Resilience::Page.extract_all  if conf.pages?
  @system_table = Resilience::SystemTable.parse
  @object_table = Resilience::ObjectTable.parse
  @root_dir     = Resilience::RootDir.parse
  @object_tree  = Resilience::ObjectTree.parse  if conf.object_tree?
end
pos() click to toggle source
# File lib/resilience/image.rb, line 48
def pos
  @file.pos - offset
end
read(len) click to toggle source
# File lib/resilience/image.rb, line 56
def read(len)
  @file.read(len)
end
seek(position) click to toggle source
# File lib/resilience/image.rb, line 44
def seek(position)
  @file.seek offset + position
end
total_pos() click to toggle source
# File lib/resilience/image.rb, line 52
def total_pos
  @file.pos
end

Private Instance Methods

parse_bounds() click to toggle source
# File lib/resilience/image.rb, line 62
def parse_bounds
  seek(ADDRESSES[:bytes_per_sector])
  @bytes_per_sector = read(4).unpack('L').first

  seek(ADDRESSES[:sectors_per_cluster])
  @sectors_per_cluster = read(4).unpack('L').first
end