| 1 |
#+TITLE: Guile-zstd: GNU Guile bindings to the zstd compression library |
| 2 |
|
| 3 |
This directory contains bindings to the zstd compression library for |
| 4 |
GNU Guile 3.0, 2.2, and 2.0: |
| 5 |
|
| 6 |
https://facebook.github.io/zstd |
| 7 |
|
| 8 |
Zstd (or “zstandard”) offers relatively high compression ratios |
| 9 |
(typically better than gzip, not as good as lzip or xz) and a high |
| 10 |
decompression throughput (noticeably higher than lzip or gzip). |
| 11 |
|
| 12 |
These bindings provide a high-level port interface for in-process |
| 13 |
compression and decompression. Here’s how you would compress a file and |
| 14 |
store its result on disk: |
| 15 |
|
| 16 |
#+begin_src scheme |
| 17 |
(use-modules (zstd) |
| 18 |
(rnrs io ports)) |
| 19 |
|
| 20 |
;; Create a compressed archive. |
| 21 |
(call-with-output-file "compressed.zst" |
| 22 |
(lambda (port) |
| 23 |
(call-with-zstd-output-port port |
| 24 |
(lambda (port) |
| 25 |
(define data |
| 26 |
;; Read the input file in memory. |
| 27 |
(call-with-input-file "input-file.txt" |
| 28 |
get-bytevector-all)) |
| 29 |
|
| 30 |
;; Write data to PORT. |
| 31 |
(put-bytevector port data))))) |
| 32 |
#+end_src |
| 33 |
|
| 34 |
Decompression works similarly: |
| 35 |
|
| 36 |
#+begin_src scheme |
| 37 |
(call-with-input-file "compressed.zst" |
| 38 |
(lambda (port) |
| 39 |
(call-with-zstd-input-port port |
| 40 |
(lambda (port) |
| 41 |
;; Read decompressed data from PORT. |
| 42 |
...)))) |
| 43 |
#+end_src |
| 44 |
|
| 45 |
* Installing |
| 46 |
|
| 47 |
With GNU Guix, you can install Guile-zstd straight of this source tree |
| 48 |
by running: |
| 49 |
|
| 50 |
#+begin_src sh |
| 51 |
guix package -f guix.scm |
| 52 |
#+end_src |
| 53 |
|
| 54 |
See the =INSTALL= file for instructions on how to build from source |
| 55 |
manually. |
| 56 |
|
| 57 |
* Hacking |
| 58 |
|
| 59 |
Using GNU Guix, you can enter a development environment by running: |
| 60 |
|
| 61 |
#+begin_src sh |
| 62 |
guix environment -CP -l guix.scm |
| 63 |
#+end_src |
| 64 |
|
| 65 |
You can authenticate the code in this repository by running: |
| 66 |
|
| 67 |
#+begin_src sh |
| 68 |
guix git authenticate \ |
| 69 |
afe022f7a1de5517dfeae66705dc21d94f4d2b0a \ |
| 70 |
3CE464558A84FDC69DB40CFB090B11993D9AEBB5 |
| 71 |
#+end_src |
| 72 |
|
| 73 |
The command silently exits with zero on success, and errors out |
| 74 |
otherwise. We recommend invoking it from ‘.git/hooks/pre-push’. |
| 75 |
|
| 76 |
* Reporting Bugs |
| 77 |
|
| 78 |
Please report bugs to <[email protected]>. |
| 79 |
|
| 80 |
|
| 81 |
Local Variables: |
| 82 |
mode: org |
| 83 |
ispell-local-dictionary: "american" |
| 84 |
End: |