gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] Better tmpfile code for gzipped streams


From: Camm Maguire
Subject: [Gcl-devel] Better tmpfile code for gzipped streams
Date: 09 Sep 2003 12:36:59 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings!  Anyone have a problem with this for opening gzipped files,
especially Windows and possible Mac OS X people?

file.d:
=============================================================================
                        if (sSAallow_gzipped_fileA->s.s_dbind != sLnil)
                          { 
                            struct stat ss;
                            char buf[256];
                            if (snprintf(buf,sizeof(buf),"%s.gz",fname)<=0)
                              FEerror("Cannot write .gz filename",0);
                            if (!stat(fname,&ss)) {
                              FILE *pp;
                              int n;
                              if (!(fp=tmpfile()))
                                FEerror("Cannot create temporary file",0);
                              if (snprintf(buf,sizeof(buf),"zcat 
%s.gz",fname)<=0)
                                FEerror("Cannot write zcat pipe name",0);
                              if (!(pp=popen(buf,"r")))
                                FEerror("Cannot open zcat pipe",0);
                              while((n=fread(buf,1,sizeof(buf),pp)))
                                if (!fwrite(buf,1,n,fp))
                                  FEerror("Cannot write pipe output to 
temporary file",0);
                              if (pclose(pp)<0)
                                FEerror("Cannot close zcat pipe",0);
                              goto AGAIN;
                            }
                          }
=============================================================================
Take care,

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

[Prev in Thread] Current Thread [Next in Thread]