MCPcopy Create free account
hub / github.com/assaultcube/AC / read

Method read

source/src/zip.cpp:353–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351 }
352
353 int read(void *buf, int len)
354 {
355 if(reading < 0 || !buf || !len) return 0;
356 if(!info->compressedsize)
357 {
358 if(arch->owner != this)
359 {
360 arch->owner = NULL;
361 if(!arch->data->seek(reading, SEEK_SET)) { stopreading(); return 0; }
362 arch->owner = this;
363 }
364
365 int n = (int)arch->data->read(buf, min(len, int(info->size + info->offset - reading)));
366 reading += n;
367 if(n < len) ended = true;
368 return n;
369 }
370
371 zfile.next_out = (Bytef *)buf;
372 zfile.avail_out = len;
373 while(zfile.avail_out > 0)
374 {
375 if(!zfile.avail_in) readbuf(BUFSIZE);
376 int err = inflate(&zfile, Z_NO_FLUSH);
377 if(err != Z_OK)
378 {
379 if(err == Z_STREAM_END) ended = true;
380 else
381 {
382#ifndef STANDALONE
383 if(dbgzip) conoutf("inflate error: %s", zError(err));
384#endif
385 stopreading();
386 }
387 break;
388 }
389 }
390 return len - zfile.avail_out;
391 }
392};
393
394// manage zips as part of the AC virtual filesystem

Callers 5

findzipdirectoryFunction · 0.45
readzipdirectoryFunction · 0.45
readlocalfileheaderFunction · 0.45
readbufMethod · 0.45
addzipmodFunction · 0.45

Calls 3

minFunction · 0.85
conoutfFunction · 0.70
seekMethod · 0.45

Tested by

no test coverage detected