Liking cljdoc? Tell your friends :D

:file_folder: clompress

Clojars Project

Clompress is easy to use library for working with archives, compression and decompression in Clojure. Currently acts like wrapper for library Apache Commons Compress

Features

Directories are readed recursively.

Supported archives

  • [x] TAR "tar"
  • [x] ZIP "zip"

Supported compressions

  • [x] BZIP2
  • [x] GZIP
  • [x] DEFLATE
  • [x] LZ4 (BLOCK, FRAMED)
  • [x] LZMA
  • [x] XZ

For available compressions:

clompress.compression/available-compressions

Installation

Lein/Boot

[com.monkeyprojects/clompress "0.1.0"]

Clojure CLI/deps.edn

com.monkeyprojects/clompress {:mvn/version "0.1.0"}

Examples

Creating archive without compression

(clompress/archive {
	:output-stream (clojure.java.io/output-stream "my-archive.tar")
	:archive-type "tar"} ; for zip set :archive-type "zip"
	"directory1/" "directory2/file1.txt" "file2.txt")

Creating archive with compression bzip2

(clompress/archive {
	:output-stream (clojure.java.io/output-stream "my-archive.tar.bz2")
	:compression "bzip2"
	:archive-type "tar"}
	"directory1/" "directory2/file1.txt" "file2.txt")

Compressing file

(clompress.compression/compress
	(clojure.java.io/input-stream "file-to-compress.txt")
	(clojure.java.io/output-stream "compressed-file.txt.gz")
	"gz")

Decompressing file

(clompress.compression/decompress
	(clojure.java.io/input-stream "compressed-file.txt.gz")
	(clojure.java.io/output-stream "decompressed-file.txt")
	"gz")

Compressing string

(with-open [input-stream (java.io.ByteArrayInputStream.
                           (.getBytes "test-data"))]
  (with-open [output-stream (java.io.ByteArrayOutputStream.)]
    (clompress.compression/compress input-stream output-stream "bzip2")))

Decompressing string

(with-open [input-stream (java.io.ByteArrayInputStream.
                           (.getBytes compressed-string))]
  (with-open [output-stream (java.io.ByteArrayOutputStream.)]
    (clompress.compression/decompress input-stream output-stream "bzip2")
		(.toString output-stream)))

License

Clompress is licensed under MIT license.

Can you improve this documentation? These fine people already did:
Spelchure & Wout Neirynck
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close