Class: XZ::LZMAStream

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/xz.rb

Overview

The main struct of the liblzma library.

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ LZMAStream

This method does basicly the same thing as the LZMA_STREAM_INIT macro of liblzma. Creates a new LZMAStream that has been initialized for usage. If any argument is passed, it is assumed to be a FFI::Pointer to a lzma_stream structure and that structure is wrapped.



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/xz.rb', line 134

def initialize(*args)
  if args.empty? #Got a pointer, want to wrap it
    super
  else
    s = super()
    s[:next] = nil
    s[:avail_in] = 0
    s[:total_in] = 0
    s[:next_out] = nil
    s[:avail_out] = 0
    s[:total_out] = 0
    s[:lzma_allocator] = nil
    s[:lzma_internal] = nil
    s[:reserved_ptr1] = nil
    s[:reserved_ptr2] = nil
    s[:reserved_ptr3] = nil
    s[:reserved_ptr4] = nil
    s[:reserved_int1] = 0
    s[:reserved_int2] = 0
    s[:reserved_int3] = 0
    s[:reserved_int4] = 0
    s[:reserved_enum1] = LibLZMA::LZMA_RESERVED_ENUM[:lzma_reserved_enum]
    s[:reserved_enum2] = LibLZMA::LZMA_RESERVED_ENUM[:lzma_reserved_enum]
    s
  end
end