Class: Cabriolet::HLP::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/cabriolet/hlp/parser.rb

Overview

Parser for HLP (Windows Help) files

NOTE: This implementation is based on the knowledge that HLP files use LZSS compression with MODE_MSHELP, but cannot be fully validated due to lack of test fixtures and incomplete libmspack implementation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io_system = nil) ⇒ Parser

Initialize parser

Parameters:

  • io_system (System::IOSystem, nil) (defaults to: nil)

    Custom I/O system or nil for default



17
18
19
# File 'lib/cabriolet/hlp/parser.rb', line 17

def initialize(io_system = nil)
  @io_system = io_system || System::IOSystem.new
end

Instance Attribute Details

#io_systemObject (readonly)

Returns the value of attribute io_system.



11
12
13
# File 'lib/cabriolet/hlp/parser.rb', line 11

def io_system
  @io_system
end

Instance Method Details

#parse(filename) ⇒ Models::HLPHeader

Parse an HLP file

Parameters:

  • filename (String)

    Path to HLP file

Returns:

Raises:

  • (Errors::ParseError)

    if file is not valid HLP



26
27
28
29
30
31
32
33
34
# File 'lib/cabriolet/hlp/parser.rb', line 26

def parse(filename)
  handle = @io_system.open(filename, Constants::MODE_READ)

  begin
    parse_header(handle)
  ensure
    @io_system.close(handle)
  end
end