added preliminary support for Gzipped I/O

parent d03b02c0
#include <cstdio>
#include <cctype>
#include "pnm.h"
#include <zlib.h>
char cmd[1024];
//
// MUST BE CLOSED WITH pclose!
//
FILE *pnm_gzopen(const char *path, const char *mode) {
FILE* f;
if (mode[0] == 'r') {
// for reading, we pipe from zcat
sprintf(cmd,"zcat \"%s\"",path);
f = popen(path,mode);
} else { // 'a' or 'w'
sprintf(cmd,"gzip > \"%s\"",path);
f = popen(path,mode);
}
return f;
}
void pnm_gzclose(FILE* f) {
pclose(f);
}
static int skip_comments(FILE *fp)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment