Fix empty file not being saved regression

When open a non-empty text file, empty the file and save it, the file is not saved on disk.
This PR has fixed this regression.

Fix #10667, close #10668
This commit is contained in:
Don Ho 2021-10-14 16:26:52 +02:00
parent 4c34652e14
commit 6cae886dde
1 changed files with 2 additions and 2 deletions

View File

@ -102,7 +102,7 @@ unsigned long Win32_IO_File::read(void *rbuf, unsigned long buf_size)
bool Win32_IO_File::write(const void *wbuf, unsigned long buf_size)
{
if (!isOpened() || (wbuf == nullptr) || (buf_size == 0) || ((_hMode != Mode::WRITE) && (_hMode != Mode::APPEND)))
if (!isOpened() || (wbuf == nullptr) || ((_hMode != Mode::WRITE) && (_hMode != Mode::APPEND)))
return false;
DWORD bytes_written = 0;
@ -110,7 +110,7 @@ bool Win32_IO_File::write(const void *wbuf, unsigned long buf_size)
if (::WriteFile(_hFile, wbuf, buf_size, &bytes_written, NULL) == FALSE)
return false;
if (!_written && (bytes_written != 0))
if (!_written)
_written = true;
return (bytes_written == buf_size);