Enhance copy/move file Win32API functions to avoid system cach

Suggestion from:
https://github.com/d0vgan/nppexec/issues/29#issuecomment-761830889
This commit is contained in:
Don HO 2021-01-19 04:05:54 +01:00
parent 45912a3321
commit 051b17ca44
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
2 changed files with 3 additions and 2 deletions

View File

@ -1566,7 +1566,8 @@ bool Notepad_plus::fileSave(BufferID id)
}
}
if (!::CopyFile(fn, fn_bak.c_str(), FALSE))
BOOL keepGoing = TRUE;
if (!::CopyFileEx(fn, fn_bak.c_str(), nullptr, nullptr, &keepGoing, COPY_FILE_NO_BUFFERING))
{
int res = _nativeLangSpeaker.messageBox("FileBackupFailed",
_pPublicInterface->getHSelf(),

View File

@ -757,7 +757,7 @@ bool FileManager::moveFile(BufferID id, const TCHAR * newFileName)
{
Buffer* buf = getBufferByID(id);
const TCHAR *fileNamePath = buf->getFullPathName();
if (::MoveFileEx(fileNamePath, newFileName, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED) == 0)
if (::MoveFileEx(fileNamePath, newFileName, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH) == 0)
return false;
buf->setFileName(newFileName);