Hi,

"Dr. Arne Babenhauserheide" <arne_...@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’.


Reply via email to