FILE* TCodaEvio::Open(const char* filename, const char* mode)
{
fIsPipe=true;
static char buf[256];
TString fstr(filename);
if (fstr.EndsWith(".bz2")) {
sprintf(buf,"bunzip2 -c %s",filename); Form("bunzip2 < %
s",filename)
return popen(buf, mode);
} else if (fstr.EndsWith(".gz")) {
sprintf(buf,"gunzip -c %s",filename);
return popen(buf, mode);
} else {
fIsPipe=false;
return fopen(filename, mode);
}
}
int TCodaEvio::Close(FILE* fp)
{
if (fIsPipe) {
//fseek(fp, 0L, SEEK_END);//doesn't work?
char buf[256];
while(fgets(buf,256,fp)) {};
return pclose(fp);
} else {
return fclose(fp);
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment