Class: Tassadar::MPQ::FileData

Inherits:
BinData::Record
  • Object
show all
Defined in:
lib/tassadar/mpq/file_data.rb

Constant Summary collapse

MPQ_FILE_ENCRYPTED =
0x00010000
MPQ_FILE_EXISTS =
0x80000000
MPQ_SINGLE_UNIT =
0x01000000
MPQ_COMPRESSED =
0x00000200

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#block_offsetObject

Returns the value of attribute block_offset.



13
14
15
# File 'lib/tassadar/mpq/file_data.rb', line 13

def block_offset
  @block_offset
end

Instance Method Details

#decompressed_dataObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/tassadar/mpq/file_data.rb', line 19

def decompressed_data
  result = nil
  block = eval_parameter(:block)

  if (block.flags & MPQ_FILE_EXISTS) > 0
    result = self.data
  end

  if (block.flags & MPQ_FILE_ENCRYPTED) > 0
    raise NotImplementedError
  end

  if (block.flags & MPQ_SINGLE_UNIT) > 0
    if block.flags & MPQ_COMPRESSED && block.file_size > block.block_size
      result = decompress(self.data)
    end
  else
  end

  result
end