Class: XZ::LZMAStream

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/xz/lib_lzma.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.



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

def initialize(*args)
  if !args.empty? #Got a pointer, want to wrap it
    super
  else
    s = super()
    s[:next_in]        = 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