Created
June 10, 2016 14:51
-
-
Save rpav/a01c6f677fade725b43ac0b2d0f7bdd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; This assumes conspack, salza2, and chipz are loaded | |
(defun compress (thing) | |
(cpk:encode | |
(salza2:compress-data (cpk:encode thing) | |
'salza2:gzip-compressor))) | |
(defun decompress (thing) | |
(cpk:decode (chipz:decompress nil 'chipz:gzip thing))) | |
(let ((array (make-array 1000000 :element-type '(unsigned-byte 8)))) | |
(with-open-file (out "somefile.cpk" | |
:direction :output | |
:if-exists :supersede | |
:element-type '(unsigned-byte 8)) | |
(loop for i from 0 below 10 | |
as chunk = (compress array) | |
do (write-sequence chunk out)))) | |
(with-open-file (in "somefile.cpk" | |
:direction :input | |
:element-type '(unsigned-byte 8)) | |
(loop with eof = nil | |
as object = (handler-case | |
(cpk:decode-stream in) | |
(end-of-file () (setf eof t) (values))) | |
until eof | |
do (let ((thing (decompress object))) | |
(format t "thing = ~S~%" (type-of thing))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment