-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
deflate.cr
38 lines (34 loc) · 936 Bytes
/
deflate.cr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require "lib_z"
require "./*"
# The Deflate module contains readers and writers of DEFLATE format compressed
# data, as specified in [RFC 1951](https://www.ietf.org/rfc/rfc1951.txt).
#
# See `Gzip`, `Zip` and `Zlib` for modules that provide access
# to DEFLATE-based file formats.
#
# NOTE: To use `Deflate` or its children, you must explicitly import it with `require "compress/deflate"`
module Compress::Deflate
NO_COMPRESSION = 0
BEST_SPEED = 1
BEST_COMPRESSION = 9
DEFAULT_COMPRESSION = -1
enum Strategy
FILTERED = 1
HUFFMAN_ONLY = 2
RLE = 3
FIXED = 4
DEFAULT = 0
end
class Error < Exception
def initialize(ret, stream)
msg = stream.msg
msg = LibZ.zError(ret) if msg.null?
if msg
error_msg = String.new(msg)
super("deflate: #{error_msg}")
else
super("deflate: #{ret}")
end
end
end
end