Class: Cabriolet::LIT::StructureBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/cabriolet/lit/structure_builder.rb

Overview

Builds complete LIT structure from file data

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io_system:, version: 1, language_id: 0x409, creator_id: 0) ⇒ StructureBuilder

Initialize structure builder

Parameters:

  • io_system (System::IOSystem)

    I/O system for file operations

  • version (Integer) (defaults to: 1)

    LIT format version

  • language_id (Integer) (defaults to: 0x409)

    Language ID

  • creator_id (Integer) (defaults to: 0)

    Creator ID



19
20
21
22
23
24
# File 'lib/cabriolet/lit/structure_builder.rb', line 19

def initialize(io_system:, version: 1, language_id: 0x409, creator_id: 0)
  @io_system = io_system
  @version = version
  @language_id = language_id
  @creator_id = creator_id
end

Instance Attribute Details

#creator_idObject (readonly)

Returns the value of attribute creator_id.



11
12
13
# File 'lib/cabriolet/lit/structure_builder.rb', line 11

def creator_id
  @creator_id
end

#io_systemObject (readonly)

Returns the value of attribute io_system.



11
12
13
# File 'lib/cabriolet/lit/structure_builder.rb', line 11

def io_system
  @io_system
end

#language_idObject (readonly)

Returns the value of attribute language_id.



11
12
13
# File 'lib/cabriolet/lit/structure_builder.rb', line 11

def language_id
  @language_id
end

#versionObject (readonly)

Returns the value of attribute version.



11
12
13
# File 'lib/cabriolet/lit/structure_builder.rb', line 11

def version
  @version
end

Instance Method Details

#build(file_data) ⇒ Hash

Build complete LIT structure from file data

Parameters:

  • file_data (Array<Hash>)

    File data array from prepare_files

Returns:

  • (Hash)

    Complete LIT structure



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cabriolet/lit/structure_builder.rb', line 30

def build(file_data)
  structure = {}

  # Generate GUIDs
  structure[:header_guid] = GuidGenerator.generate
  structure[:piece3_guid] = Binary::LITStructures::GUIDs::PIECE3
  structure[:piece4_guid] = Binary::LITStructures::GUIDs::PIECE4

  # Build directory
  structure[:directory] = build_directory(file_data)

  # Build sections
  structure[:sections] = build_sections

  # Build manifest
  structure[:manifest] = build_manifest(file_data)

  # Build secondary header metadata
  structure[:secondary_header] = 

  # Calculate piece offsets and sizes
  structure[:pieces] = calculate_pieces(structure)

  # Update secondary header with content offset
  update_secondary_header_content_offset(structure)

  # Store metadata
  structure[:version] = @version
  structure[:file_data] = file_data

  structure
end