Clompress is easy to use library for working with archives, compression and decompression in Clojure. Currently acts like wrapper for library Apache Commons Compress
Directories are readed recursively.
- TAR
"tar"
- ZIP
"zip"
- BZIP2
- GZIP
- DEFLATE
- LZ4 (BLOCK, FRAMED)
- LZMA
- XZ
For available compressions:
clompress.compression/available-compressions
[org.clojars.alperenbayramoglu/clompress "0.1.0"]
org.clojars.alperenbayramoglu/clompress {:mvn/version "0.1.0"}
(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")
(clompress/archive {
:output-stream (clojure.java.io/output-stream "my-archive.tar.bz2")
:compression "bzip2"
:archive-type "tar"}
"directory1/" "directory2/file1.txt" "file2.txt")
(clompress.compression/compress
(clojure.java.io/input-stream "file-to-compress.txt")
(clojure.java.io/output-stream "compressed-file.txt.gz")
"gz")
(clompress.compression/decompress
(clojure.java.io/input-stream "compressed-file.txt.gz")
(clojure.java.io/output-stream "decompressed-file.txt")
"gz")
(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")))
(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)))