[NEW_FEATURE] Automatic Backup System (in progress).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1204 f5eea248-9336-0410-98b8-ebc06183d4e3
remotes/trunk
Don Ho 11 years ago
parent 9c9fa8c484
commit 7cbcc1f902

@ -5760,26 +5760,7 @@ int Notepad_plus::getQuoteIndexFrom(const char *quoter) const
void Notepad_plus::showAllQuotes() const
{
/*
HANDLE mutex = ::CreateMutex(NULL, false, TEXT("nppTextWriter"));
for (int i = 0; i < nbQuote; i++)
{
static bool firstTime = true;
if (firstTime)
{
firstTime = false;
}
else
{
WaitForSingleObject(mutex, INFINITE);
}
ReleaseMutex(mutex);
Sleep(1000);
showQuoteFromIndex(i);
WaitForSingleObject(mutex, INFINITE);
}
*/
}
void Notepad_plus::showQuoteFromIndex(int index) const

@ -615,12 +615,18 @@ bool FileManager::moveFile(BufferID id, const TCHAR * newFileName)
bool FileManager::backupBuffer(BufferID id, const TCHAR * filename)
{
// This method is called from 2 differents place, so synchronization is important
HANDLE mutex = ::CreateMutex(NULL, false, TEXT("nppBackupSystem"));
::WaitForSingleObject(mutex, INFINITE);
Buffer * buffer = getBufferByID(id);
TCHAR fullpath[MAX_PATH];
::GetFullPathName(filename, MAX_PATH, fullpath, NULL);
::GetLongPathName(fullpath, fullpath, MAX_PATH);
bool result = false;
/*
time_t currentBakModifTimestamp = buffer->getBackupModifiedTimeStamp();
time_t lastBakModifTimestamp = 0;
@ -687,33 +693,33 @@ bool FileManager::backupBuffer(BufferID id, const TCHAR * filename)
// Error, we didn't write the entire document to disk.
// Note that fwrite() doesn't return the number of bytes written, but rather the number of ITEMS.
if(items_written != 1)
if(items_written == 1)
{
return false;
}
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
/*
if (lastBakModifTimestamp != 0)
buffer->setBackupModifiedTimeStamp(lastBakModifTimestamp);
else
{
struct _stat statBuf;
if (!generic_stat(fullpath, &statBuf))
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
/*
if (lastBakModifTimestamp != 0)
buffer->setBackupModifiedTimeStamp(lastBakModifTimestamp);
else
{
buffer->setBackupModifiedTimeStamp(statBuf.st_mtime);
struct _stat statBuf;
if (!generic_stat(fullpath, &statBuf))
{
buffer->setBackupModifiedTimeStamp(statBuf.st_mtime);
}
}
}
*/
*/
buffer->setModifiedStatus(false);
buffer->setModifiedStatus(false);
return true; //all done
result = true; //all done
}
}
return false; // fopen failed
}
return true; // buffer dirty nut unmodified
else // buffer dirty but unmodified
{
result = true;
}
}
else // buffer not dirty, sync: delete the backup file
{
@ -722,10 +728,12 @@ bool FileManager::backupBuffer(BufferID id, const TCHAR * filename)
{
// delete backup file
return true; // backup file deleted
}
return true; // no backup file to delete
result = true; // no backup file to delete
}
::ReleaseMutex(mutex);
return result;
}
bool FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool isCopy, generic_string * error_msg)

Loading…
Cancel
Save