Unix Programming - Any system call from decompress .Z or .gz files?

This is Interesting: Free IT Magazines  
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, 7:21 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, 1: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
Fred Kleinschmidt

2007-07-11, 7:28 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


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com