changeset 400: |
122554547517 |
parent 399: |
7963217e1d39 |
child 401: |
b10f5822bc58 |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Sun, 02 Jun 2024 22:34:29 -0400 |
files: |
lisp/lib/io/flate.lisp |
description: |
init flate.lisp |
1.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2+++ b/lisp/lib/io/flate.lisp Sun Jun 02 22:34:29 2024 -0400
1.3@@ -0,0 +1,55 @@
1.4+;;; io/flate.lisp --- Compressed IO Interface
1.5+
1.6+;; Use compression (ZSTD) with Lisp objects and streams.
1.7+
1.8+;;; Commentary:
1.9+
1.10+;; compression ref: https://www.xach.com/lisp/salza2/ (compression only)
1.11+
1.12+;; decompression ref: https://github.com/sharplispers/chipz (decompression only)
1.13+
1.14+;; The libraries above are the current state-of-the-art for compression and
1.15+;; decompression in Common Lisp. They are portable packages which depend on
1.16+;; gray streams. They loosely cover deflate, zlib, gzip, and bzip2 data.
1.17+
1.18+;; The compression backends are themselves hand-coded in Common Lisp, making
1.19+;; them excellent reference material. However, we don't have much use for the
1.20+;; compression backend offered.
1.21+
1.22+;; We intend to almost exclusively support Zstd compression and decompression
1.23+;; using our ZSTD FFI Lisp system, so we'll make a new library - FLATE - which
1.24+;; provides a shared zstd compression/decompression to Lisp objects and
1.25+;; streams.
1.26+
1.27+;;; Code:
1.28+(in-package :io/flate)
1.29+
1.30+;;; Vars
1.31+
1.32+;;; Utils
1.33+
1.34+;;; Compression
1.35+
1.36+;; (Deflate)
1.37+
1.38+;;; Decompression
1.39+
1.40+;; (Inflate)
1.41+
1.42+;; From chipz:
1.43+;; We provide several convenience functions for decompression:
1.44+;;
1.45+;; * decompress a buffer to a newly-consed buffer;
1.46+;; * decompress a stream to a newly-consed buffer;
1.47+;; * decompress a pathname to a newly-consed buffer;
1.48+;; * decompress a buffer to a user-specified buffer;
1.49+;; * decompress a buffer to a stream;
1.50+;; * decompress a stream to a stream.
1.51+;; * decompress a pathname to another pathname;
1.52+;; * decompress a pathname to a stream;
1.53+;;
1.54+;; We do not provide stream->buffer decompression, as we have no way of
1.55+;; knowing how much to read from the stream to fill the buffer, no way
1.56+;; of determining what to do with possible state left in the
1.57+;; INFLATE-STATE that we used, etc. Application-specific logic will
1.58+;; have to handle those bits.