Module: Omnizip::Formats::Ole
- Defined in:
- lib/omnizip/formats/ole.rb,
lib/omnizip/formats/ole/dirent.rb,
lib/omnizip/formats/ole/header.rb,
lib/omnizip/formats/ole/storage.rb,
lib/omnizip/formats/ole/constants.rb,
lib/omnizip/formats/ole/ranges_io.rb,
lib/omnizip/formats/ole/types/variant.rb,
lib/omnizip/formats/ole/allocation_table.rb
Overview
OLE compound document format support
Provides read access to Microsoft OLE compound documents, commonly used for .doc, .xls, .ppt files and MSI installers.
Defined Under Namespace
Modules: Constants, Types Classes: AllocationTable, Dirent, Header, RangesIO, RangesIOMigrateable, RangesIOResizeable, Storage
Class Method Summary collapse
-
.directory?(ole_path, entry_path) ⇒ Boolean
Check if entry is a directory (storage).
-
.exist?(ole_path, entry_path) ⇒ Boolean
Check if entry exists in OLE file.
-
.extract(ole_path, output_dir) ⇒ Object
Extract all streams to directory.
-
.file?(ole_path, entry_path) ⇒ Boolean
Check if entry is a file (stream).
-
.info(ole_path, entry_path = "/") ⇒ Hash?
Get info about entry in OLE file.
-
.list(path, dir_path = "/") ⇒ Array<String>
List entries in OLE file.
-
.open(path) {|Storage| ... } ⇒ Storage
Open OLE file.
-
.read(ole_path, stream_path) ⇒ String
Read stream from OLE file.
-
.register! ⇒ Object
Register OLE format in registry.
Class Method Details
.directory?(ole_path, entry_path) ⇒ Boolean
Check if entry is a directory (storage)
106 107 108 |
# File 'lib/omnizip/formats/ole.rb', line 106 def directory?(ole_path, entry_path) self.open(ole_path) { |ole| ole.directory?(entry_path) } end |
.exist?(ole_path, entry_path) ⇒ Boolean
Check if entry exists in OLE file
88 89 90 |
# File 'lib/omnizip/formats/ole.rb', line 88 def exist?(ole_path, entry_path) self.open(ole_path) { |ole| ole.exist?(entry_path) } end |
.extract(ole_path, output_dir) ⇒ Object
Extract all streams to directory
114 115 116 117 118 |
# File 'lib/omnizip/formats/ole.rb', line 114 def extract(ole_path, output_dir) self.open(ole_path) do |ole| extract_dirent(ole.root, output_dir, ole) end end |
.file?(ole_path, entry_path) ⇒ Boolean
Check if entry is a file (stream)
97 98 99 |
# File 'lib/omnizip/formats/ole.rb', line 97 def file?(ole_path, entry_path) self.open(ole_path) { |ole| ole.file?(entry_path) } end |
.info(ole_path, entry_path = "/") ⇒ Hash?
Get info about entry in OLE file
79 80 81 |
# File 'lib/omnizip/formats/ole.rb', line 79 def info(ole_path, entry_path = "/") self.open(ole_path) { |ole| ole.info(entry_path) } end |
.list(path, dir_path = "/") ⇒ Array<String>
List entries in OLE file
61 62 63 |
# File 'lib/omnizip/formats/ole.rb', line 61 def list(path, dir_path = "/") self.open(path) { |ole| ole.list(dir_path) } end |
.open(path) {|Storage| ... } ⇒ Storage
Open OLE file
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/omnizip/formats/ole.rb', line 43 def open(path) storage = Storage.open(path) if block_given? begin yield storage ensure storage.close end else storage end end |
.read(ole_path, stream_path) ⇒ String
Read stream from OLE file
70 71 72 |
# File 'lib/omnizip/formats/ole.rb', line 70 def read(ole_path, stream_path) self.open(ole_path) { |ole| ole.read(stream_path) } end |
.register! ⇒ Object
Register OLE format in registry
121 122 123 124 125 126 |
# File 'lib/omnizip/formats/ole.rb', line 121 def register! FormatRegistry.register(".ole", Storage) FormatRegistry.register(".doc", Storage) FormatRegistry.register(".xls", Storage) FormatRegistry.register(".ppt", Storage) end |