Unix system programming - unzipping a file programmatically

What I need to do is unzip the file (.gz or .z), read the first line and do something according to the first line. But the C standard library does not offer a way to do this.

Is it platform independent?

+3
source share
3 answers

Use "zlib", a library that performs compression and decompression:

http://www.zlib.net/

It is included in the database of all Unix distributions, and you can easily link your program with it for the Windows version and send the DLL.

+11
source

Info-zip libraries are pretty portable.

0

If you want a platform-independent one, you will need to unzip the code in your program. Most likely, you will want to establish a connection with a third-party library, for example ZLib , which is standard for Unix systems or uses a DLL in Windows.

The rest is pretty simple: use ZLib to unzip the file to a temporary location, read the file as usual, then delete the file when you're done.

0
source

Source: https://habr.com/ru/post/1734585/


All Articles