Module: LZMA::Utils

Extended by:
Utils
Included in:
LZMA, Utils
Defined in:
lib/extlzma.rb,
ext/utils.c

Defined Under Namespace

Classes: CRC32, CRC64

Instance Method Summary collapse

Instance Method Details

#block_buffer_bound(uncompressed_size) ⇒ Object



83
84
85
86
87
# File 'ext/utils.c', line 83

static VALUE
utils_block_buffer_bound(VALUE mod, VALUE size)
{
    return SIZET2NUM(lzma_block_buffer_bound(NUM2SIZET(size)));
}

#LZMA::Utils.crc32(string, crc = 0) ⇒ Object

liblzmaに含まれるlzma_crc32を呼び出します。



31
32
33
34
35
# File 'ext/utils.c', line 31

static VALUE
utils_crc32(int argc, VALUE argv[], VALUE self)
{
    return crc_calc((void *(*)(va_list *))crc32_update, argc, argv);
}

#crc32_digest(seq, init = 0) ⇒ Object



374
375
376
# File 'lib/extlzma.rb', line 374

def crc32_digest(seq, init = 0)
  [Utils.crc32(seq, init)].pack("N")
end

#crc32_hexdigest(seq, init = 0) ⇒ Object



378
379
380
# File 'lib/extlzma.rb', line 378

def crc32_hexdigest(seq, init = 0)
  "%08X" % Utils.crc32(seq, init)
end

#LZMA::Utils.crc64(string, crc = 0) ⇒ Object

liblzmaに含まれるlzma_crc64を呼び出します。



53
54
55
56
57
# File 'ext/utils.c', line 53

static VALUE
utils_crc64(int argc, VALUE argv[], VALUE self)
{
    return crc_calc((void *(*)(va_list *))crc64_update, argc, argv);
}

#crc64_digest(seq, init = 0) ⇒ Object



382
383
384
# File 'lib/extlzma.rb', line 382

def crc64_digest(seq, init = 0)
  [Utils.crc64(seq, init)].pack("Q>")
end

#crc64_hexdigest(seq, init = 0) ⇒ Object



386
387
388
# File 'lib/extlzma.rb', line 386

def crc64_hexdigest(seq, init = 0)
  "%016X" % Utils.crc64(seq, init)
end

#lookup_error(lzma_ret) ⇒ Object



63
64
65
66
67
# File 'ext/utils.c', line 63

static VALUE
utils_lookup_error(VALUE mod, VALUE status)
{
    return extlzma_lookup_error(NUM2INT(status));
}

#raise_err(lzma_ret, mesg = nil) ⇒ Object

Raises:

  • (et)


482
483
484
485
# File 'lib/extlzma.rb', line 482

def raise_err(lzma_ret, mesg = nil)
  et = Utils.lookup_error(lzma_ret)
  raise et, mesg, caller
end

#stream_buffer_bound(uncompressed_size) ⇒ Object



73
74
75
76
77
# File 'ext/utils.c', line 73

static VALUE
utils_stream_buffer_bound(VALUE mod, VALUE size)
{
    return SIZET2NUM(lzma_stream_buffer_bound(NUM2SIZET(size)));
}