07-11-07 06:22 PM
redbox <guojianlee@gmail.com> wrote:
> Any system call from decompress .Z or .gz files?
There aren't any "system calls" for uncompressing files. While
there exist some libraries for that (see e.g. www.zlib.net),
the simplest solution probably is to spawn gunzip (which can
handle both .Z and .gz files) as a process and read the decom-
pressed file content from it's output. I.e., in a very simp-
listic fashion:
FILE *fp;
fp = popen( "gunzip -c filename", "r" );
/* now read from fp like a normal file until you reach
the end of the file */
....
pclose( fp );
Getting it right with error checking etc. of course takes
a bit more of work.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
[ Post a follow-up to this message ]
|