[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Guile-zstd 0.1.1 released
From: |
Ludovic Courtès |
Subject: |
Re: Guile-zstd 0.1.1 released |
Date: |
Mon, 04 Jan 2021 18:21:19 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Hi,
"Dr. Arne Babenhauserheide" <arne_bab@web.de> skribis:
> Looking at the readme I get the feeling that two little helpers could be
> useful:
>
> (call-with-zstd-output-file "compressed.zstd"
> (lambda (port)
> (define data
> ;; Read the input file in memory.
> (call-with-input-file "input-file.txt"
> get-bytevector-all))
>
> ;; Write data to PORT.
> (put-bytevector port data)))
>
> (call-with-zstd-input-file "compressed.zst"
> (lambda (port)
> ;; Read decompressed data from PORT.
> ...))
>
> Potentially with streaming added (if that’s possible from the library):
>
> (call-with-zstd-output-file "compressed.zstd"
> (lambda (outport)
> (call-with-input-file "input-file.txt"
> (lambda (inport)
> (let loop ((data (get-bytevector-some inport)))
> (when (not (eof-object? data))
> (put-bytevector outport data)
> (loop (get-bytevector-some inport))))))))
Yeah I kept it minimal; it’s actually the same interface as in
Guile-zlib and Guile-lzlib, which is pretty convenient.
Thanks,
Ludo’.
- Re: Guile-zstd 0.1.1 released,
Ludovic Courtès <=