mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-28 16:24:27 +02:00
Fix file saving critical bug under Symantec encryption desktop
Fix #11339, close #11403
This commit is contained in:
parent
10ec944800
commit
d9c5688635
@ -127,7 +127,7 @@ void writeLog(const TCHAR *logFileName, const char *log2write)
|
||||
const DWORD accessParam{ GENERIC_READ | GENERIC_WRITE };
|
||||
const DWORD shareParam{ FILE_SHARE_READ | FILE_SHARE_WRITE };
|
||||
const DWORD dispParam{ OPEN_ALWAYS }; // Open existing file for writing without destroying it or create new
|
||||
const DWORD attribParam{ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH };
|
||||
const DWORD attribParam{ FILE_ATTRIBUTE_NORMAL };
|
||||
HANDLE hFile = ::CreateFileW(logFileName, accessParam, shareParam, NULL, dispParam, attribParam, NULL);
|
||||
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
@ -149,6 +149,7 @@ void writeLog(const TCHAR *logFileName, const char *log2write)
|
||||
::WriteFile(hFile, log2writeStr.c_str(), static_cast<DWORD>(log2writeStr.length()), &bytes_written, NULL);
|
||||
|
||||
::FlushFileBuffers(hFile);
|
||||
::CloseHandle(hFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,11 @@ void Win32_IO_File::close()
|
||||
{
|
||||
if (isOpened())
|
||||
{
|
||||
DWORD flushError = NOERROR;
|
||||
if (_written)
|
||||
{
|
||||
::FlushFileBuffers(_hFile);
|
||||
if (!::FlushFileBuffers(_hFile))
|
||||
flushError = ::GetLastError();
|
||||
}
|
||||
::CloseHandle(_hFile);
|
||||
|
||||
@ -74,7 +76,20 @@ void Win32_IO_File::close()
|
||||
generic_string nppIssueLog = nppParam.getUserPath();
|
||||
pathAppend(nppIssueLog, issueFn);
|
||||
|
||||
std::string msg = _path;
|
||||
|
||||
std::string msg;
|
||||
if (flushError != NOERROR)
|
||||
{
|
||||
LPSTR messageBuffer = nullptr;
|
||||
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
nullptr, flushError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, nullptr);
|
||||
msg += messageBuffer;
|
||||
|
||||
//Free the buffer.
|
||||
LocalFree(messageBuffer);
|
||||
msg += "\n";
|
||||
}
|
||||
msg += _path;
|
||||
msg += " is closed.";
|
||||
writeLog(nppIssueLog.c_str(), msg.c_str());
|
||||
}
|
||||
|
@ -59,5 +59,5 @@ private:
|
||||
const DWORD _accessParam { GENERIC_READ | GENERIC_WRITE };
|
||||
const DWORD _shareParam { FILE_SHARE_READ | FILE_SHARE_WRITE };
|
||||
const DWORD _dispParam { CREATE_ALWAYS };
|
||||
const DWORD _attribParam { FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH };
|
||||
const DWORD _attribParam { FILE_ATTRIBUTE_NORMAL };
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user