MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / gz_open

Function gz_open

extlibs/minizip/src/gzlib.c:93–281  ·  view source on GitHub ↗

Open a gzip file either by name or file descriptor. */

(path, fd, mode)

Source from the content-addressed store, hash-verified

91
92/* Open a gzip file either by name or file descriptor. */
93local gzFile gz_open(path, fd, mode)
94 const
95void* path;
96int fd;
97
98const char* mode;
99{
100 gz_statep state;
101 z_size_t len;
102 int oflag;
103#ifdef O_CLOEXEC
104 int cloexec = 0;
105#endif
106#ifdef O_EXCL
107 int exclusive = 0;
108#endif
109
110 /* check input */
111 if (path == NULL)
112 return NULL;
113
114 /* allocate gzFile structure to return */
115 state = (gz_statep)malloc(sizeof(gz_state));
116 if (state == NULL)
117 return NULL;
118 state->size = 0; /* no buffers allocated yet */
119 state->want = GZBUFSIZE; /* requested buffer size */
120 state->msg = NULL; /* no error message yet */
121
122 /* interpret mode */
123 state->mode = GZ_NONE;
124 state->level = Z_DEFAULT_COMPRESSION;
125 state->strategy = Z_DEFAULT_STRATEGY;
126 state->direct = 0;
127 while (*mode)
128 {
129 if (*mode >= '0' && *mode <= '9')
130 state->level = *mode - '0';
131 else
132 switch (*mode)
133 {
134 case 'r':
135 state->mode = GZ_READ;
136 break;
137#ifndef NO_GZCOMPRESS
138 case 'w':
139 state->mode = GZ_WRITE;
140 break;
141 case 'a':
142 state->mode = GZ_APPEND;
143 break;
144#endif
145 case '+': /* can't read and write at the same time */
146 free(state);
147 return NULL;
148 case 'b': /* ignore -- will request binary anyway */
149 break;
150#ifdef O_CLOEXEC

Callers 4

gzopenFunction · 0.85
gzopen64Function · 0.85
gzdopenFunction · 0.85
gzopen_wFunction · 0.85

Calls 1

gz_resetFunction · 0.85

Tested by

no test coverage detected