MCPcopy Create free account
hub / github.com/F-Stack/f-stack / gz_skip

Function gz_skip

freebsd/contrib/zstd/zlibWrapper/gzread.c:271–300  ·  view source on GitHub ↗

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

(state, len)

Source from the content-addressed store, hash-verified

269
270/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */
271local int gz_skip(state, len)
272 gz_statep state;
273 z_off64_t len;
274{
275 unsigned n;
276
277 /* skip over len bytes or reach end-of-file, whichever comes first */
278 while (len)
279 /* skip over whatever is in output buffer */
280 if (state.state->x.have) {
281 n = GT_OFF(state.state->x.have) || (z_off64_t)state.state->x.have > len ?
282 (unsigned)len : state.state->x.have;
283 state.state->x.have -= n;
284 state.state->x.next += n;
285 state.state->x.pos += n;
286 len -= n;
287 }
288
289 /* output buffer empty -- return if we're at the end of the input */
290 else if (state.state->eof && state.state->strm.avail_in == 0)
291 break;
292
293 /* need more data to skip -- load up output buffer */
294 else {
295 /* get more output, looking for header if required */
296 if (gz_fetch(state) == -1)
297 return -1;
298 }
299 return 0;
300}
301
302/* Read len bytes into buf from file, or less than len up to the end of the
303 input. Return the number of bytes read. If zero is returned, either the

Callers 3

gz_readFunction · 0.70
gzungetcFunction · 0.70
gzread.cFile · 0.70

Calls 1

gz_fetchFunction · 0.70

Tested by

no test coverage detected