Class Ole::Storage
In: lib/ole/storage/meta_data.rb
lib/ole/storage/version.rb
lib/ole/storage/base.rb
lib/ole/storage/file_system.rb
Parent: Object

This class is the primary way the user interacts with an OLE storage file.

TODO

  • the custom header cruft for Header and Dirent needs some love.
  • i have a number of classes doing load/save combos: Header, AllocationTable, Dirent, and, in a manner of speaking, but arguably different, Storage itself. they have differing api‘s which would be nice to rethink. AllocationTable::Big must be created aot now, as it is used for all subsequent reads.

Methods

bat_for_size   clear   close   dir   dirent_from_path   file   flush   inspect   load   meta_data   new   open   repack   repack_using_io  

Classes and Modules

Class Ole::Storage::AllocationTable
Class Ole::Storage::DirClass
Class Ole::Storage::Dirent
Class Ole::Storage::FileClass
Class Ole::Storage::Header
Class Ole::Storage::MetaData
Class Ole::Storage::RangesIOMigrateable
Class Ole::Storage::RangesIOResizeable

Constants

VERSION = '1.2.11.2'

Attributes

bbat  [R]  Low level internals, you probably shouldn‘t need to mess with these
close_parent  [R]  The underlying io object to/from which the ole object is serialized, whether we should close it, and whether it is writeable
dirents  [R]  The tree structure in its original flattened form. only valid after load, or flush.
header  [R]  Low level internals, you probably shouldn‘t need to mess with these
io  [R]  The underlying io object to/from which the ole object is serialized, whether we should close it, and whether it is writeable
params  [R]  options used at creation time
root  [R]  The top of the ole tree structure
sb_file  [R]  Low level internals, you probably shouldn‘t need to mess with these
sbat  [R]  Low level internals, you probably shouldn‘t need to mess with these
writeable  [R]  The underlying io object to/from which the ole object is serialized, whether we should close it, and whether it is writeable

Public Class methods

arg should be either a filename, or an IO object, and needs to be seekable. mode is optional, and should be a regular mode string.

somewhat similar to File.open, the open class method allows a block form where the Ole::Storage object is automatically closed on completion of the block.

Public Instance methods

tries to get a dirent for path. return nil if it doesn‘t exist (change it)

the flush method is the main "save" method. all file contents are always written directly to the file by the RangesIO objects, all this method does is write out all the file meta data - dirents, allocation tables, file header etc.

maybe add an option to zero the padding, and any remaining avail blocks in the allocation table.

TODO: long and overly complex. simplify and test better. eg, perhaps move serialization of bbat to AllocationTable::Big.

load document from file.

TODO: implement various allocationtable checks, maybe as a AllocationTable#fsck function :)

  1. reterminate any chain not ending in EOC. compare file size with actually allocated blocks per file.
  2. pass through all chain heads looking for collisions, and making sure nothing points to them (ie they are really heads). in both sbat and mbat
  3. we know the locations of the bbat data, and mbat data. ensure that there are placeholder blocks in the bat for them.
  4. maybe a check of excess data. if there is data outside the bbat.truncate.length + 1 * block_size, (eg what is used for truncate in flush), then maybe add some sort of message about that. it will be automatically thrown away at close time.

could be useful with mis-behaving ole documents. or to just clean them up.

[Validate]