Home > Archive > Unix Programming > July 2007 > Any system call from decompress .Z or .gz files?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Any system call from decompress .Z or .gz files?
|
|
| redbox 2007-07-11, 4:14 am |
| Any system call from decompress .Z or .gz files?
i google it ,but can't found anythis!
Thank u
| |
| Jens Thoms Toerring 2007-07-11, 8:06 am |
| 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
| |
| Fred Kleinschmidt 2007-07-11, 7:07 pm |
|
"redbox" <guojianlee@gmail.com> wrote in message
news:1184140110.349558.128120@d30g2000prg.googlegroups.com...
> Any system call from decompress .Z or .gz files?
> i google it ,but can't found anythis!
> Thank u
>
zcat, gunzip, ...
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Aero Stability and Controls Computing
| |
|
|
|
|
|