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

Function gz_load

extlibs/minizip/src/gzread.c:21–51  ·  view source on GitHub ↗

Use read() to load a buffer -- return -1 on error, otherwise 0. Read from state->fd, and update state->eof, state->err, and state->msg as appropriate. This function needs to loop on read(), since read() is not guaranteed to read the number of bytes requested, depending on the type of descriptor. */

(state, buf, len, have)

Source from the content-addressed store, hash-verified

19 This function needs to loop on read(), since read() is not guaranteed to
20 read the number of bytes requested, depending on the type of descriptor. */
21local int gz_load(state, buf, len, have)
22gz_statep state;
23unsigned char* buf;
24unsigned len;
25
26unsigned* have;
27{
28 int ret;
29 unsigned get, max = ((unsigned)-1 >> 2) + 1;
30
31 *have = 0;
32 do
33 {
34 get = len - *have;
35 if (get > max)
36 get = max;
37 ret = read(state->fd, buf + *have, get);
38 if (ret <= 0)
39 break;
40 *have += (unsigned)ret;
41 }
42 while (*have < len);
43 if (ret < 0)
44 {
45 gz_error(state, Z_ERRNO, zstrerror());
46 return -1;
47 }
48 if (ret == 0)
49 state->eof = 1;
50 return 0;
51}
52
53/* Load up input buffer and set eof flag if last data loaded -- return -1 on
54 error, 0 otherwise. Note that the eof flag is set when the end of the input

Callers 3

gz_availFunction · 0.85
gz_fetchFunction · 0.85
gz_readFunction · 0.85

Calls 1

gz_errorFunction · 0.85

Tested by

no test coverage detected