diff --git a/PowerEditor/src/MISC/Common/FileInterface.cpp b/PowerEditor/src/MISC/Common/FileInterface.cpp index 866e01535..6634ce2a7 100644 --- a/PowerEditor/src/MISC/Common/FileInterface.cpp +++ b/PowerEditor/src/MISC/Common/FileInterface.cpp @@ -100,6 +100,7 @@ void Win32_IO_File::close() if (!::FlushFileBuffers(_hFile)) { flushError = ::GetLastError(); + std::wstring errNumberMsg = std::to_wstring(flushError) + L" - " + GetLastErrorAsString(flushError); if (!nppParam.isEndSessionCritical()) { @@ -133,9 +134,21 @@ void Win32_IO_File::close() errMsg += L"\n\nThat file, temporarily stored in the system cache, cannot be finally committed to the storage device selected! \ This is probably a storage driver or hardware issue, beyond the control of the Notepad++. \ Please try using another storage and also check if your saved data is not corrupted.\n\nError Code reported: "; - errMsg += std::to_wstring(flushError) + L" - " + GetLastErrorAsString(flushError); + errMsg += errNumberMsg; ::MessageBoxW(NULL, errMsg.c_str(), L"WARNING - filebuffer flushing fail!", MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL); } + else + { + // writing breif log here + std::wstring nppFlushFileBuffersFailsLog = L"nppFlushFileBuffersFails.log"; + std::wstring nppIssueLog = nppParam.getUserPath(); + pathAppend(nppIssueLog, nppFlushFileBuffersFailsLog); + + std::wstring_convert> converter; + std::string errNumberMsgA = converter.to_bytes(errNumberMsg); + + writeLog(nppIssueLog.c_str(), errNumberMsgA.c_str()); + } } } ::CloseHandle(_hFile); @@ -152,6 +165,8 @@ Please try using another storage and also check if your saved data is not corrup std::string msg; if (flushError != NOERROR) { + msg = "FlushFileBuffers failed with the error code: " + std::to_string(flushError) + " - "; + 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); diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index 7c7d5d058..64349aa88 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -139,7 +139,7 @@ void Buffer::setLangType(LangType lang, const TCHAR* userLangName) void Buffer::updateTimeStamp() { - FILETIME timeStampLive = {}; + FILETIME timeStampLive {}; WIN32_FILE_ATTRIBUTE_DATA attributes{}; if (GetFileAttributesEx(_fullPathName.c_str(), GetFileExInfoStandard, &attributes) != 0) {