In my linux program, I want to decompress a tar.gz file contents to a specific directory. Is there any system call or any C++ class available in C/C++ to extract file contents from tar.gz file?
The tar command manipulates archives by writing files to, or retrieving files from an archive storage medium. The files used by the tar command are represented by the File parameter.
The main features of 7-Zip Supported formats: Packing / unpacking: 7z, XZ, BZIP2, GZIP, TAR, ZIP and WIM.
There is excellent library libarchive, which supports accessing multiple archive formats using consistent API. You can follow these examples on how to use it.
If you are on Ubuntu, you can easily install this library using command sudo apt-get install libarchive-dev
. On other platforms, you may need to download source code and compile this library yourself.
One advantage of using libarchive vs. using system()
calls is not depending on system utilities, and also it should work faster because it does not fork.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With