3

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?

helpermethod
  • 59,493
  • 71
  • 188
  • 276

3 Answers3

11

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

http://www.zlib.net/

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.

Zorglub
  • 2,077
  • 1
  • 19
  • 22
0

The info-zip libraries are quite portable.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
0

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.

Tarka
  • 4,041
  • 2
  • 22
  • 33