LZ4算法实现对文件目录的压缩

我使用LZ4算法实现了对文件目录的压缩,方法就是将每个文件都压缩成一个LZ4格式,然后记录文件名字和长度,再将这些文件拼成一个大文件,但是速度比较慢。因为产生了中间文件。(也可以先拼接成一个大文件,然后再使用LZ4压缩。后面试一下。)我去问LZ4研发团队,他们给出了在windows和Linux上面压缩目录的方法。

项目地址:

https://github.com/lz4/lz4

issue地址:

https://github.com/lz4/lz4/issues/627

下面是他们的回复:

If you wish to compress directories, the correct way is to archive the directory, typically using tar, then pass the archive to lz4, producing a .tar.lz4 file.

On Unix systems, this association is pretty straightforward :
tar -cf - target_directory | lz4 -c > archive.tar.lz4
or
tar -I lz4 -cf archive.tar.lz4 target_directory

On Windows, it can be more difficult, depending on exact development environment. tar may or may not be available.

If you are used to GUI, you can use 7-zip Zstandard edition by @mcmilk, which includes an lz4 codec. There's also a command line version, available at : https://github.com/mcmilk/7-Zip-zstd

猜你喜欢

转载自blog.csdn.net/xikangsoon/article/details/85242093
LZ4