54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
-
-
+
-
-
-
-
-
-
-
|
}
// Decompress the data from the given io.Reader and write it to the given io.Writer
// I/O is buffered for better performance
func decompress(output io.Writer, input io.Reader) int {
var (
err error
buffer io.Writer = iou.SizedWriter(output, 4096)
decompressor io.Reader = predictor.Decompressor(iou.SizedReader(input, 4096))
)
_, err = io.Copy(buffer, decompressor)
_, err = io.Copy(output, decompressor)
if err != nil {
fmt.Fprintln(os.Stderr, "Error while decompressing.\n", err)
return 1
}
// Flush the buffer
_, err = buffer.Write(nil)
if err != nil {
fmt.Fprintln(os.Stderr, "Error while flushing output buffer.\n", err)
return 1
}
return 0
}
|