MCPcopy Create free account
hub / github.com/NetHack/NetHack / lib_dlb_fread

Function lib_dlb_fread

src/dlb.c:298–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296}
297
298staticfn int
299lib_dlb_fread(char *buf, int size, int quan, dlb *dp)
300{
301 long pos, nread, nbytes;
302
303 /* make sure we don't read into the next file */
304 if ((dp->size - dp->mark) < (size * quan))
305 quan = (int)((dp->size - dp->mark) / size);
306 if (quan == 0)
307 return 0;
308
309 pos = dp->start + dp->mark;
310 if (dp->lib->fmark != pos) {
311 fseek(dp->lib->fdata, pos, SEEK_SET); /* check for error??? */
312 dp->lib->fmark = pos;
313 }
314
315 nread = fread(buf, size, quan, dp->lib->fdata);
316 nbytes = nread * size;
317 dp->mark += nbytes;
318 dp->lib->fmark += nbytes;
319
320 return (int) nread;
321}
322
323staticfn int
324lib_dlb_fseek(dlb *dp, long pos, int whence)

Callers 1

lib_dlb_fgetcFunction · 0.85

Calls 2

fseekFunction · 0.85
freadFunction · 0.85

Tested by

no test coverage detected