What I need to do is unzip a file, (.gz or .z), read the first line and do some stuff according to the first line read. But the C standard library doesn't seem to offer a way to do this.
Is the a platform-independent way to do it?
What I need to do is unzip a file, (.gz or .z), read the first line and do some stuff according to the first line read. But the C standard library doesn't seem to offer a way to do this.
Is the a platform-independent way to do it?
Use "zlib", the library that performs compression and decompression:
It's included in the base of all Unix distributions, and you can easily link your program against it for the windows version and ship the DLL.
if you want to platform-independent, you'd have to have the unzipping code in your program. Likely, you'd want to link against a third-party library, such as ZLib which is standard on Unix systems, or use the DLL when on Windows.
The rest is pretty simple: use ZLib to unzip the file to a temporary location, read the file as normal, then remove the file when you're done.