Aravinth Sankar
Aravinth Sankar

Reputation: 19

Compress a directory using LZ4 in C++

My objective is to compress a whole directory using LZ4. I have the code to compress a single file. So I iterated over directory and sub-directories and compressed every file with (.lz4) extension (Eg: filename.txt to filename.txt.lz4). The result I get is a directory containing the compressed files. But I want the output to be an archive file. I don't know which file extension the resultant folder should be archived (zip, tar). Also, how to do that in C++. Thanks in advance.

Upvotes: 0

Views: 1425

Answers (2)

Mark Adler
Mark Adler

Reputation: 112642

You need to make a tar file, which is an uncompressed archive of your files and directories, and then compress that with lz4. libarchive can help with the tar part.

Upvotes: 2

Cyan
Cyan

Reputation: 13988

Try this command line :

tar cvf - directory | lz4 - archive.tar.lz4

Regeneration will be

lz4 archive.tar.lz4 - | tar xvf -

Upvotes: 0

Related Questions