Module: LZMA::Utils

Defined in:
lib/extlzma2/utils.rb,
ext/extlzma2/utils.c

Defined Under Namespace

Classes: CRC32, CRC64

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.crc32_digest(seq, init = 0) ⇒ Object



5
6
7
# File 'lib/extlzma2/utils.rb', line 5

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

.crc32_hexdigest(seq, init = 0) ⇒ Object



9
10
11
# File 'lib/extlzma2/utils.rb', line 9

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

.crc64_digest(seq, init = 0) ⇒ Object



13
14
15
# File 'lib/extlzma2/utils.rb', line 13

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

.crc64_hexdigest(seq, init = 0) ⇒ Object



17
18
19
# File 'lib/extlzma2/utils.rb', line 17

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

Instance Method Details

#block_buffer_bound(uncompressed_size) ⇒ Object



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

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を呼び出します。



28
29
30
31
# File 'ext/extlzma2/utils.c', line 28

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

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

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



47
48
49
50
# File 'ext/extlzma2/utils.c', line 47

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

#lookup_error(lzma_ret) ⇒ Object



56
57
58
59
# File 'ext/extlzma2/utils.c', line 56

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

#raise_err(lzma_ret, mesg = nil) ⇒ Object

Raises:

  • (et)


99
100
101
102
# File 'lib/extlzma2/utils.rb', line 99

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

#stream_buffer_bound(uncompressed_size) ⇒ Object



65
66
67
68
# File 'ext/extlzma2/utils.c', line 65

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