Class: MppReader::Cfbf::Header
- Inherits:
-
Object
- Object
- MppReader::Cfbf::Header
- Defined in:
- lib/mpp_reader/cfbf/header.rb
Constant Summary collapse
- SIGNATURE =
"\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1".b.freeze
Instance Attribute Summary collapse
-
#difat_head ⇒ Object
readonly
Returns the value of attribute difat_head.
-
#first_difat_sector ⇒ Object
readonly
Returns the value of attribute first_difat_sector.
-
#first_dir_sector ⇒ Object
readonly
Returns the value of attribute first_dir_sector.
-
#first_minifat_sector ⇒ Object
readonly
Returns the value of attribute first_minifat_sector.
-
#mini_sector_size ⇒ Object
readonly
Returns the value of attribute mini_sector_size.
-
#mini_stream_cutoff ⇒ Object
readonly
Returns the value of attribute mini_stream_cutoff.
-
#num_difat_sectors ⇒ Object
readonly
Returns the value of attribute num_difat_sectors.
-
#num_fat_sectors ⇒ Object
readonly
Returns the value of attribute num_fat_sectors.
-
#num_minifat_sectors ⇒ Object
readonly
Returns the value of attribute num_minifat_sectors.
-
#sector_size ⇒ Object
readonly
Returns the value of attribute sector_size.
Instance Method Summary collapse
-
#initialize(bytes) ⇒ Header
constructor
A new instance of Header.
Constructor Details
#initialize(bytes) ⇒ Header
Returns a new instance of Header.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mpp_reader/cfbf/header.rb', line 19 def initialize(bytes) unless bytes && bytes.bytesize >= 512 && bytes.byteslice(0, 8) == SIGNATURE raise InvalidFormatError, "not an OLE2 compound file (bad signature)" end sector_shift = bytes.byteslice(30, 2).unpack1("v") mini_shift = bytes.byteslice(32, 2).unpack1("v") unless sector_shift == 9 || sector_shift == 12 raise InvalidFormatError, "invalid sector shift #{sector_shift} (must be 9 or 12)" end unless mini_shift == 6 raise InvalidFormatError, "invalid mini sector shift #{mini_shift} (must be 6)" end @sector_size = 1 << sector_shift @mini_sector_size = 1 << mini_shift @num_fat_sectors, @first_dir_sector, _txn_sig, @mini_stream_cutoff, @first_minifat_sector, @num_minifat_sectors, @first_difat_sector, @num_difat_sectors = bytes.byteslice(44, 32).unpack("V8") @difat_head = bytes.byteslice(76, 436).unpack("V109") end |
Instance Attribute Details
#difat_head ⇒ Object (readonly)
Returns the value of attribute difat_head.
14 15 16 |
# File 'lib/mpp_reader/cfbf/header.rb', line 14 def difat_head @difat_head end |
#first_difat_sector ⇒ Object (readonly)
Returns the value of attribute first_difat_sector.
14 15 16 |
# File 'lib/mpp_reader/cfbf/header.rb', line 14 def first_difat_sector @first_difat_sector end |
#first_dir_sector ⇒ Object (readonly)
Returns the value of attribute first_dir_sector.
14 15 16 |
# File 'lib/mpp_reader/cfbf/header.rb', line 14 def first_dir_sector @first_dir_sector end |
#first_minifat_sector ⇒ Object (readonly)
Returns the value of attribute first_minifat_sector.
14 15 16 |
# File 'lib/mpp_reader/cfbf/header.rb', line 14 def first_minifat_sector @first_minifat_sector end |
#mini_sector_size ⇒ Object (readonly)
Returns the value of attribute mini_sector_size.
14 15 16 |
# File 'lib/mpp_reader/cfbf/header.rb', line 14 def mini_sector_size @mini_sector_size end |
#mini_stream_cutoff ⇒ Object (readonly)
Returns the value of attribute mini_stream_cutoff.
14 15 16 |
# File 'lib/mpp_reader/cfbf/header.rb', line 14 def mini_stream_cutoff @mini_stream_cutoff end |
#num_difat_sectors ⇒ Object (readonly)
Returns the value of attribute num_difat_sectors.
14 15 16 |
# File 'lib/mpp_reader/cfbf/header.rb', line 14 def num_difat_sectors @num_difat_sectors end |
#num_fat_sectors ⇒ Object (readonly)
Returns the value of attribute num_fat_sectors.
14 15 16 |
# File 'lib/mpp_reader/cfbf/header.rb', line 14 def num_fat_sectors @num_fat_sectors end |
#num_minifat_sectors ⇒ Object (readonly)
Returns the value of attribute num_minifat_sectors.
14 15 16 |
# File 'lib/mpp_reader/cfbf/header.rb', line 14 def num_minifat_sectors @num_minifat_sectors end |
#sector_size ⇒ Object (readonly)
Returns the value of attribute sector_size.
14 15 16 |
# File 'lib/mpp_reader/cfbf/header.rb', line 14 def sector_size @sector_size end |