[MODIF] Modify the N++ recovery dir into to %temp%.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@375 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
0c6496f6b3
commit
56e1ac8939
|
@ -2848,7 +2848,9 @@ void Notepad_plus::command(int id)
|
|||
switch (id)
|
||||
{
|
||||
case IDM_FILE_NEW:
|
||||
{
|
||||
fileNew();
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_FILE_OPEN:
|
||||
|
@ -8789,30 +8791,17 @@ bool Notepad_plus::str2Cliboard(const TCHAR *str2cpy)
|
|||
|
||||
//ONLY CALL IN CASE OF EMERGENCY: EXCEPTION
|
||||
//This function is destructive
|
||||
bool Notepad_plus::emergency() {
|
||||
const TCHAR * outdir = TEXT("C:\\N++RECOV");
|
||||
bool Notepad_plus::emergency(generic_string emergencySavedDir)
|
||||
{
|
||||
bool filestatus = false;
|
||||
bool dumpstatus = false;
|
||||
do {
|
||||
if (::CreateDirectory(outdir, NULL) == FALSE && ::GetLastError() != ERROR_ALREADY_EXISTS) {
|
||||
if (::CreateDirectory(emergencySavedDir.c_str(), NULL) == FALSE && ::GetLastError() != ERROR_ALREADY_EXISTS) {
|
||||
break;
|
||||
}
|
||||
|
||||
filestatus = dumpFiles(outdir, TEXT("File"));
|
||||
/*
|
||||
HANDLE hProcess = ::GetCurrentProcess();
|
||||
DWORD processId = ::GetCurrentProcessId();
|
||||
filestatus = dumpFiles(emergencySavedDir.c_str(), TEXT("File"));
|
||||
|
||||
TCHAR dumpFile[MAX_PATH];
|
||||
_snprintf(dumpFile, MAX_PATH, TEXT("%s\\NPP_DUMP.dmp"), outdir);
|
||||
HANDLE hFile = ::CreateFile(dumpFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
::MessageBox(NULL, TEXT("Failed to write dump file!"), dumpFile, MB_OK|MB_ICONWARNING);
|
||||
}
|
||||
|
||||
BOOL ret = ::MiniDumpWriteDump(hProcess, processId, hFile, MiniDumpNormal, NULL, NULL, NULL); //might want to add exception info aswell
|
||||
dumpstatus = (ret == TRUE);
|
||||
*/
|
||||
} while (false);
|
||||
|
||||
bool status = filestatus;// && dumpstatus;
|
||||
|
|
|
@ -94,8 +94,8 @@ struct PostItConf {
|
|||
bool isToolbarShown;
|
||||
bool isTabbarShown;
|
||||
bool isStatusbarShown;
|
||||
PostItConf() : isPostIt(true), isSizable(false), isAlwaysOnTop(true),\
|
||||
isMenuShown(false), isToolbarShown(false), isTabbarShown(false), isStatusbarShown(false){};
|
||||
PostItConf() : isPostIt(false), isSizable(true), isAlwaysOnTop(false),\
|
||||
isMenuShown(true), isToolbarShown(true), isTabbarShown(true), isStatusbarShown(true){};
|
||||
};
|
||||
|
||||
class FileDialog;
|
||||
|
@ -200,7 +200,8 @@ public:
|
|||
bool loadSession(Session & session);
|
||||
winVer getWinVersion() const {return _winVersion;};
|
||||
|
||||
bool emergency();
|
||||
bool emergency(generic_string emergencySavedDir);
|
||||
|
||||
void notifyBufferChanged(Buffer * buffer, int mask);
|
||||
bool findInFiles();
|
||||
|
||||
|
|
|
@ -321,9 +321,17 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR cmdLineAnsi, int nCmdSh
|
|||
void doException(Notepad_plus & notepad_plus_plus) {
|
||||
Win32Exception::removeHandler(); //disable exception handler after excpetion, we dont want corrupt data structurs to crash the exception handler
|
||||
printMsg(TEXT("Notepad++ will attempt to save any unsaved data. However, dataloss is very likely."), TEXT("Recovery initiating"), MB_OK | MB_ICONINFORMATION);
|
||||
bool res = notepad_plus_plus.emergency();
|
||||
|
||||
TCHAR tmpDir[1024];
|
||||
GetTempPath(1024, tmpDir);
|
||||
generic_string emergencySavedDir = tmpDir;
|
||||
emergencySavedDir += TEXT("\\N++RECOV");
|
||||
|
||||
bool res = notepad_plus_plus.emergency(emergencySavedDir);
|
||||
if (res) {
|
||||
printMsg(TEXT("Notepad++ was able to successfully recover some unsaved documents, or nothing to be saved could be found.\r\nYou can find the results at N++RECOV directory, located in your system temporary directory."), TEXT("Recovery success"), MB_OK | MB_ICONINFORMATION);
|
||||
generic_string displayText = TEXT("Notepad++ was able to successfully recover some unsaved documents, or nothing to be saved could be found.\r\nYou can find the results at :\r\n");
|
||||
displayText += emergencySavedDir;
|
||||
printMsg(displayText.c_str(), TEXT("Recovery success"), MB_OK | MB_ICONINFORMATION);
|
||||
} else {
|
||||
printMsg(TEXT("Unfortunatly, Notepad++ was not able to save your work. We are sorry for any lost data."), TEXT("Recovery failure"), MB_OK | MB_ICONERROR);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue