Class: Mapi::Pst::BlockPtr

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(data, is64) ⇒ BlockPtr

Returns a new instance of BlockPtr.

Parameters:

  • data (String, Array)
  • is64 (Boolean)


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

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



369
370
371
# File 'lib/mapi/pst.rb', line 369

def id
  @id
end

#offsetObject

Returns the value of attribute offset

Returns:

  • (Object)

    the current value of offset



369
370
371
# File 'lib/mapi/pst.rb', line 369

def offset
  @offset
end

#pstPst

Returns:



379
380
381
# File 'lib/mapi/pst.rb', line 379

def pst
  @pst
end

#sizeObject

Returns the value of attribute size

Returns:

  • (Object)

    the current value of size



369
370
371
# File 'lib/mapi/pst.rb', line 369

def size
  @size
end

#u1Object

Returns the value of attribute u1

Returns:

  • (Object)

    the current value of u1



369
370
371
# File 'lib/mapi/pst.rb', line 369

def u1
  @u1
end

Instance Method Details

#data?Boolean

Returns:

  • (Boolean)


409
410
411
# File 'lib/mapi/pst.rb', line 409

def data?
	(id & 0x2) == 0
end

#inspectObject

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

Returns:

  • (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

#typeSymbol

Returns:

  • (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