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

Function gzread

extlibs/minizip/src/gzread.c:414–449  ·  view source on GitHub ↗

-- see zlib.h -- */

(file, buf, len)

Source from the content-addressed store, hash-verified

412
413/* -- see zlib.h -- */
414int ZEXPORT gzread(file, buf, len)
415gzFile file;
416voidp buf;
417
418unsigned len;
419{
420 gz_statep state;
421
422 /* get internal structure */
423 if (file == NULL)
424 return -1;
425 state = (gz_statep)file;
426
427 /* check that we're reading and that there's no (serious) error */
428 if (state->mode != GZ_READ ||
429 (state->err != Z_OK && state->err != Z_BUF_ERROR))
430 return -1;
431
432 /* since an int is returned, make sure len fits in one, otherwise return
433 with an error (this avoids a flaw in the interface) */
434 if ((int)len < 0)
435 {
436 gz_error(state, Z_STREAM_ERROR, "request does not fit in an int");
437 return -1;
438 }
439
440 /* read len or fewer bytes to buf */
441 len = gz_read(state, buf, len);
442
443 /* check for an error */
444 if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR)
445 return -1;
446
447 /* return the number of bytes read (this is assured to fit in an int) */
448 return (int)len;
449}
450
451/* -- see zlib.h -- */
452z_size_t ZEXPORT gzfread(buf, size, nitems, file)

Callers

nothing calls this directly

Calls 2

gz_errorFunction · 0.85
gz_readFunction · 0.85

Tested by

no test coverage detected