parent
fe7257faf1
commit
38ddd32ac5
@ -1176,7 +1176,11 @@ bool Notepad_plus::fileSave(BufferID id)
|
||||
fn_bak = fn;
|
||||
}
|
||||
fn_bak += TEXT(".bak");
|
||||
::CopyFile(fn, fn_bak.c_str(), FALSE);
|
||||
|
||||
if (not ::CopyFile(fn, fn_bak.c_str(), FALSE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (backup == bak_verbose)
|
||||
{
|
||||
@ -1221,7 +1225,10 @@ bool Notepad_plus::fileSave(BufferID id)
|
||||
fn_dateTime_bak += tmpbuf;
|
||||
fn_dateTime_bak += TEXT(".bak");
|
||||
|
||||
::CopyFile(fn, fn_dateTime_bak.c_str(), FALSE);
|
||||
if (not ::CopyFile(fn, fn_dateTime_bak.c_str(), FALSE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return doSave(bufferID, buf->getFullPathName(), false);
|
||||
}
|
||||
|
@ -805,22 +805,30 @@ bool FileManager::backupCurrentBuffer()
|
||||
// Synchronization
|
||||
// This method is called from 2 differents place, so synchronization is important
|
||||
HANDLE writeEvent = ::OpenEvent(EVENT_ALL_ACCESS, TRUE, TEXT("nppWrittingEvent"));
|
||||
if (!writeEvent)
|
||||
if (not writeEvent)
|
||||
{
|
||||
// no thread yet, create a event with non-signaled, to block all threads
|
||||
writeEvent = ::CreateEvent(NULL, TRUE, FALSE, TEXT("nppWrittingEvent"));
|
||||
if (not writeEvent)
|
||||
{
|
||||
printStr(TEXT("CreateEvent problem in backupCurrentBuffer()!"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (::WaitForSingleObject(writeEvent, INFINITE) != WAIT_OBJECT_0)
|
||||
{
|
||||
// problem!!!
|
||||
printStr(TEXT("WaitForSingleObject problem in backupCurrentBuffer()!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// unlocled here, set to non-signaled state, to block all threads
|
||||
::ResetEvent(writeEvent);
|
||||
if (not ::ResetEvent(writeEvent))
|
||||
{
|
||||
printStr(TEXT("ResetEvent problem in backupCurrentBuffer()!"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
UniMode mode = buffer->getUnicodeMode();
|
||||
|
Loading…
Reference in New Issue
Block a user