msvcrt: Implement bufsiz block flushing behavior.
This commit is contained in:
parent
c6a160691a
commit
ad968be779
|
@ -3720,6 +3720,18 @@ MSVCRT_size_t CDECL MSVCRT_fwrite(const void *ptr, MSVCRT_size_t size, MSVCRT_si
|
|||
}
|
||||
written += wrcnt;
|
||||
wrcnt = 0;
|
||||
} else if(file->_bufsiz && wrcnt >= file->_bufsiz) {
|
||||
MSVCRT_size_t pcnt=(wrcnt / file->_bufsiz) * file->_bufsiz;
|
||||
if(msvcrt_flush_buffer(file) == MSVCRT_EOF)
|
||||
break;
|
||||
|
||||
if(MSVCRT__write(file->_file, ptr, pcnt) <= 0) {
|
||||
file->_flag |= MSVCRT__IOERR;
|
||||
break;
|
||||
}
|
||||
written += pcnt;
|
||||
wrcnt -= pcnt;
|
||||
ptr = (const char*)ptr + pcnt;
|
||||
} else {
|
||||
if(MSVCRT__flsbuf(*(const char*)ptr, file) == MSVCRT_EOF)
|
||||
break;
|
||||
|
|
|
@ -2243,7 +2243,7 @@ static void test_write_flush_size(FILE *file, int bufsize)
|
|||
fseek(file, 0, SEEK_SET);
|
||||
ok(fread(inbuffer, 1, bufsize, file) == bufsize, "read failed\n");
|
||||
if (size == bufsize)
|
||||
todo_wine ok(memcmp(outbuffer, inbuffer, bufsize) == 0, "missing flush by %d byte write\n", size);
|
||||
ok(memcmp(outbuffer, inbuffer, bufsize) == 0, "missing flush by %d byte write\n", size);
|
||||
else
|
||||
ok(memcmp(outbuffer, inbuffer, bufsize) != 0, "unexpected flush by %d byte write\n", size);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue