Add the deplete operation at the data stream

It's used to read the content file up to the end to verify its CRC.
This commit is contained in:
Andrea Mazzoleni 2015-10-28 19:36:24 +01:00
parent 104c47d106
commit 7e1d9138b5
3 changed files with 65 additions and 28 deletions

View file

@ -1564,26 +1564,7 @@ static void decoding_error(const char* path, STREAM* f)
log_fatal("Decoding error in '%s' at offset %" PRIi64 "\n", path, stell(f));
buf[0] = 0;
buf[1] = 0;
buf[2] = 0;
buf[3] = 0;
/* read until the end of the file */
while (1) {
int c = sgetc(f);
if (c == EOF) {
break;
}
/* keep the last four bytes */
buf[0] = buf[1];
buf[1] = buf[2];
buf[2] = buf[3];
buf[3] = c;
}
if (serror(f)) {
if (sdeplete(f, buf) != 0) {
/* LCOV_EXCL_START */
log_fatal("Error flushing the content file '%s' at offset %" PRIi64 "\n", path, stell(f));
exit(EXIT_FAILURE);