class XZ::LZMAStream

The main struct of the liblzma library.

Public Class Methods

new(*args) click to toggle source

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.

Calls superclass method
# File lib/xz/lib_lzma.rb, line 136
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