(in-package #:lempel) (defun compress-file (input-path output-path) (let ((file (str:read-file input-path))) (with-open-file (output output-path :direction :output :if-does-not-exist :create :if-exists :supersede :element-type '(unsigned-byte 8)) (write-sequence (prefix-encode (compress file) #xAE) output))) t) (defun decompress-file (input-path output-path) (let ((file (read-file input-path))) (with-open-file (output output-path :direction :output :if-does-not-exist :create :if-exists :supersede :element-type :default) (write-sequence (prefix-decode file #xAE) output))) t) (declaim (ftype (function (string) (array (unsigned-byte 8))) read-file)) (defun read-file (path) (with-open-file (file path :element-type '(unsigned-byte 8)) (let* ((size (file-length file)) (buf (make-array size :element-type '(unsigned-byte 8)))) (read-sequence buf file) buf)))