From 6cae886dde02106835a496e61d32509b8b9ded20 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Thu, 14 Oct 2021 16:26:52 +0200 Subject: [PATCH] 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 --- PowerEditor/src/MISC/Common/FileInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/MISC/Common/FileInterface.cpp b/PowerEditor/src/MISC/Common/FileInterface.cpp index af0deda8e..db73debff 100644 --- a/PowerEditor/src/MISC/Common/FileInterface.cpp +++ b/PowerEditor/src/MISC/Common/FileInterface.cpp @@ -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);