[NEW_FEATURE] Automatic Backup System (in progress).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1209 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2014-04-01 22:52:12 +00:00
parent 098084a378
commit 4a794ac8b1
3 changed files with 13 additions and 33 deletions

View File

@ -4245,7 +4245,7 @@ bool Notepad_plus::getIntegralDockingData(tTbData & dockData, int & iCont, bool
}
void Notepad_plus::getCurrentOpenedFiles(Session & session)
void Notepad_plus::getCurrentOpenedFiles(Session & session, bool /*includUntitledDoc*/)
{
_mainEditView.saveCurrentPos(); //save position so itll be correct in the session
_subEditView.saveCurrentPos(); //both views

View File

@ -271,7 +271,7 @@ public:
(NppParameters::getInstance())->writeFindHistory();
};
void getCurrentOpenedFiles(Session & session);
void getCurrentOpenedFiles(Session & session, bool includUntitledDoc = false);
bool fileLoadSession(const TCHAR *fn = NULL);
const TCHAR * fileSaveSession(size_t nbFile, TCHAR ** fileNames, const TCHAR *sessionFile2save);

View File

@ -621,23 +621,8 @@ bool FileManager::backupCurrentBuffer()
Buffer * buffer = _pNotepadPlus->getCurrentBuffer();
bool result = false;
bool hasModifForSession = false;
/*
time_t currentBakModifTimestamp = buffer->getBackupModifiedTimeStamp();
time_t lastBakModifTimestamp = 0;
if (PathFileExists(fullpath))
{
struct _stat statBuf;
if (!generic_stat(fullpath, &statBuf))
{
if (currentBakModifTimestamp == statBuf.st_mtime)
return true;
lastBakModifTimestamp = statBuf.st_mtime;
}
}
*/
if (buffer->isDirty())
{
if (buffer->isModified()) // buffer dirty and modified, write the backup file
@ -724,23 +709,9 @@ bool FileManager::backupCurrentBuffer()
// Note that fwrite() doesn't return the number of bytes written, but rather the number of ITEMS.
if(items_written == 1)
{
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
/*
if (lastBakModifTimestamp != 0)
buffer->setBackupModifiedTimeStamp(lastBakModifTimestamp);
else
{
struct _stat statBuf;
if (!generic_stat(fullpath, &statBuf))
{
buffer->setBackupModifiedTimeStamp(statBuf.st_mtime);
}
}
*/
buffer->setModifiedStatus(false);
hasModifForSession = true;
result = true; //all done
}
}
@ -759,11 +730,20 @@ bool FileManager::backupCurrentBuffer()
generic_string file2Delete = buffer->getBackupFileName();
buffer->setBackupFileName(TEXT(""));
result = (::DeleteFile(file2Delete.c_str()) != 0);
hasModifForSession = true;
}
//printStr(TEXT("backup deleted in backupCurrentBuffer"));
result = true; // no backup file to delete
}
//printStr(TEXT("backup sync"));
/*
if (hasModifForSession && nppgui._rememberLastSession && _rememberThisSession)
{
Session currentSession;
getCurrentOpenedFiles(currentSession);
saveSession(currentSession);
}
*/
::ReleaseMutex(mutex);
return result;
}