|
|
@ -15,13 +15,12 @@ static inline int sfread(void* out, size_t *restrict size, FILE* f)
|
|
|
|
return !!(*size = (size_t)fread(out, 1, *size, f));
|
|
|
|
return !!(*size = (size_t)fread(out, 1, *size, f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int fwrite_all(const void* buf, size_t esz, size_t num, FILE* out)
|
|
|
|
static int fwrite_all(const void* _buf, size_t sz, size_t num, FILE* out)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
register size_t w, done=0;
|
|
|
|
register size_t w, done=0;
|
|
|
|
register size_t fsz = esz * num;
|
|
|
|
register const unsigned char* buf = _buf;
|
|
|
|
const char* tbuf = (const char*)buf;
|
|
|
|
while( (w = fwrite(buf+done, sz, num-done, out)) > 0 && done < num) done+=w;
|
|
|
|
while( (w = fwrite(tbuf+done, 1, fsz-done, out)) > 0 && done < fsz) done+=w;
|
|
|
|
if (done!=num) return 0;
|
|
|
|
if (done!=fsz) return 0;
|
|
|
|
|
|
|
|
else return 1;
|
|
|
|
else return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|