MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / gz_skip

Function gz_skip

extern/zlib/src/gzread.c:236–262  ·  view source on GitHub ↗

Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */

Source from the content-addressed store, hash-verified

234
235/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */
236local int gz_skip(gz_statep state, z_off64_t len) {
237 unsigned n;
238
239 /* skip over len bytes or reach end-of-file, whichever comes first */
240 while (len)
241 /* skip over whatever is in output buffer */
242 if (state->x.have) {
243 n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ?
244 (unsigned)len : state->x.have;
245 state->x.have -= n;
246 state->x.next += n;
247 state->x.pos += n;
248 len -= n;
249 }
250
251 /* output buffer empty -- return if we're at the end of the input */
252 else if (state->eof && state->strm.avail_in == 0)
253 break;
254
255 /* need more data to skip -- load up output buffer */
256 else {
257 /* get more output, looking for header if required */
258 if (gz_fetch(state) == -1)
259 return -1;
260 }
261 return 0;
262}
263
264/* Read len bytes into buf from file, or less than len up to the end of the
265 input. Return the number of bytes read. If zero is returned, either the

Callers 3

gz_readFunction · 0.85
gzungetcFunction · 0.85
gzgetsFunction · 0.85

Calls 1

gz_fetchFunction · 0.85

Tested by

no test coverage detected