Class: Mapi::Pst::BlockPtr
- Inherits:
-
Struct
- Object
- Struct
- Mapi::Pst::BlockPtr
- Defined in:
- lib/mapi/pst.rb
Overview
pst_index
Constant Summary collapse
- UNPACK_STR32 =
'VVvv'
- UNPACK_STR64 =
'TTvv'
- SIZE32 =
12
- SIZE64 =
24
- BLOCK_SIZE =
index blocks was 516 but bogus
512
- COUNT_MAX32 =
max active items (ITEM_COUNT_OFFSET / Index::SIZE = 41)
41
- COUNT_MAX64 =
bit of a guess really. 512 / 24 = 21, but doesn’t leave enough header room
20
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#offset ⇒ Object
Returns the value of attribute offset.
- #pst ⇒ Pst
-
#size ⇒ Object
Returns the value of attribute size.
-
#u1 ⇒ Object
Returns the value of attribute u1.
Instance Method Summary collapse
- #data? ⇒ Boolean
-
#initialize(data, is64) ⇒ BlockPtr
constructor
A new instance of BlockPtr.
-
#inspect ⇒ Object
show all numbers in hex.
- #read(decrypt = true) ⇒ String
- #type ⇒ Symbol
Constructor Details
#initialize(data, is64) ⇒ BlockPtr
Returns a new instance of BlockPtr.
383 384 385 386 |
# File 'lib/mapi/pst.rb', line 383 def initialize data, is64 data = Pst.unpack data, (is64 ? UNPACK_STR64 : UNPACK_STR32) if String === data super(*data) end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id
369 370 371 |
# File 'lib/mapi/pst.rb', line 369 def id @id end |
#offset ⇒ Object
Returns the value of attribute offset
369 370 371 |
# File 'lib/mapi/pst.rb', line 369 def offset @offset end |
#size ⇒ Object
Returns the value of attribute size
369 370 371 |
# File 'lib/mapi/pst.rb', line 369 def size @size end |
#u1 ⇒ Object
Returns the value of attribute u1
369 370 371 |
# File 'lib/mapi/pst.rb', line 369 def u1 @u1 end |
Instance Method Details
#data? ⇒ Boolean
409 410 411 |
# File 'lib/mapi/pst.rb', line 409 def data? (id & 0x2) == 0 end |
#inspect ⇒ Object
show all numbers in hex
421 422 423 |
# File 'lib/mapi/pst.rb', line 421 def inspect super.gsub(/=(\d+)/) { '=0x%x' % $1.to_i }.sub(/Index /, "Index type=#{type.inspect}, ") end |
#read(decrypt = true) ⇒ String
414 415 416 417 418 |
# File 'lib/mapi/pst.rb', line 414 def read decrypt=true # only data blocks are every encrypted decrypt = false unless data? pst.pst_read_block_size offset, size, decrypt end |
#type ⇒ Symbol
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
# File 'lib/mapi/pst.rb', line 389 def type @type ||= begin if id & 0x2 == 0 :data else first_byte, second_byte = read.unpack('CC') if first_byte == 1 raise second_byte unless second_byte == 1 :data_chain_header elsif first_byte == 2 raise second_byte unless second_byte == 0 :id2_assoc else raise FormatError, 'unknown first byte for block - %p' % first_byte end end end end |