diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2011-10-02 13:24:43 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2011-10-02 13:34:29 -0700 |
commit | 26a99cd8957db86bdc75d9d1ebf00146cb20c87c (patch) | |
tree | 2f65d57da589c9e5475902fdf08a4aa8c4294bda /gzlib.c | |
parent | 3c9d261809bfafc4350147ade7b74022dd144d32 (diff) |
Add a transparent write mode to gzopen() when 'T' is in the mode.
Diffstat (limited to 'gzlib.c')
-rw-r--r-- | gzlib.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -79,7 +79,6 @@ local void gz_reset(state) if (state->mode == GZ_READ) { /* for reading ... */ state->eof = 0; /* not at end of file */ state->how = LOOK; /* look for gzip header */ - state->direct = 1; /* default for empty file */ } state->seek = 0; /* no seek request pending */ gz_error(state, Z_OK, NULL); /* clear error */ @@ -111,6 +110,7 @@ local gzFile gz_open(path, fd, mode) state->mode = GZ_NONE; state->level = Z_DEFAULT_COMPRESSION; state->strategy = Z_DEFAULT_STRATEGY; + state->direct = 0; while (*mode) { if (*mode >= '0' && *mode <= '9') state->level = *mode - '0'; @@ -143,6 +143,8 @@ local gzFile gz_open(path, fd, mode) break; case 'F': state->strategy = Z_FIXED; + case 'T': + state->direct = 1; default: /* could consider as an error, but just ignore */ ; } @@ -155,6 +157,15 @@ local gzFile gz_open(path, fd, mode) return NULL; } + /* can't force transparent read */ + if (state->mode == GZ_READ) { + if (state->direct) { + free(state); + return NULL; + } + state->direct = 1; /* for empty file */ + } + /* save the path name for error messages */ state->path = malloc(strlen(path) + 1); if (state->path == NULL) { |