README 2.0 KB

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