Class: Mapi::Pst

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/mapi/pst.rb

Overview

Read Outlook's pst file

Defined Under Namespace

Classes: Attachment, FormatError, Item, Recipient

Instance Method Summary collapse

Constructor Details

#initialize(io, helper = nil) ⇒ Pst

Returns a new instance of Pst.

Parameters:

  • io (IO)
  • helper (Helper, nil) (defaults to: nil)

Raises:



311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/mapi/pst.rb', line 311

def initialize io, helper=nil
	# corresponds to
	# * pst_open
	# * pst_load_index

	@io = io
	io.pos = 0
	@helper = helper || Helper.new
	@header = Header.new io.read(Header::SIZE)

	# would prefer this to be in Header#validate, but it doesn't have the io size.
	# should perhaps downgrade this to just be a warning...
	raise FormatError, "header size field invalid (#{header.size} != #{io.size}}" unless header.size == io.size

	load_block_btree
	load_node_btree
	load_xattrib

	@special_folder_ids = {}
end

Instance Method Details

#each {|message| ... } ⇒ void

This method returns an undefined value.

Iterate all kind of items recursively stored in this MessageStore.

Yields:

  • (message)

Yield Parameters:



1977
1978
1979
1980
1981
# File 'lib/mapi/pst.rb', line 1977

def each(&block)
	root = self.root
	block[root]
	root.each_recursive(&block)
end

#inspectObject



1990
1991
1992
# File 'lib/mapi/pst.rb', line 1990

def inspect
	"#<Pst name=#{name.inspect} io=#{io.inspect}>"
end

#nameString

Get this MessageStore's display name.

Returns:

  • (String)


1986
1987
1988
# File 'lib/mapi/pst.rb', line 1986

def name
	@name ||= root_item.props.display_name
end

#rootItem

Obtain a root item

Returns:



1965
1966
1967
# File 'lib/mapi/pst.rb', line 1965

def root
	root_item
end