[5/5] msvcrt: Implement bufsiz block flushing behavior. (try 3)
Grazvydas Ignotas
notasas at gmail.com
Fri Jun 13 18:23:58 CDT 2014
---
dlls/msvcrt/file.c | 15 +++++++++++++++
dlls/msvcrt/tests/file.c | 2 +-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index d6fb9ef..bf07bdb 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -3722,6 +3722,21 @@ 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_set_write_direction(file) != 0)
+ break;
+
+ 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;
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c
index c98adf4..62c6b07 100644
--- a/dlls/msvcrt/tests/file.c
+++ b/dlls/msvcrt/tests/file.c
@@ -2242,7 +2242,7 @@ static void test_write_flush_size(FILE *file, size_t 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);
}
--
1.7.9.5
More information about the wine-patches
mailing list