[BUG_FIXED] Make the "recovery system" for 3 mandatory xml files (config.xml, langs.xml and stylers.xml) to prevent the fail loading due to the corrupted files.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@77 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
011f2fcbc6
commit
74d580d949
|
@ -131,6 +131,14 @@ bool NppParameters::load(/*bool noUserPath*/)
|
||||||
strcpy(langs_xml_path, nppPath);
|
strcpy(langs_xml_path, nppPath);
|
||||||
|
|
||||||
PathAppend(langs_xml_path, "langs.xml");
|
PathAppend(langs_xml_path, "langs.xml");
|
||||||
|
if (!PathFileExists(langs_xml_path))
|
||||||
|
{
|
||||||
|
char srcLangsPath[MAX_PATH];
|
||||||
|
strcpy(srcLangsPath, nppPath);
|
||||||
|
PathAppend(srcLangsPath, "langs.model.xml");
|
||||||
|
|
||||||
|
::CopyFile(srcLangsPath, langs_xml_path, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
_pXmlDoc = new TiXmlDocument(langs_xml_path);
|
_pXmlDoc = new TiXmlDocument(langs_xml_path);
|
||||||
bool loadOkay = _pXmlDoc->LoadFile();
|
bool loadOkay = _pXmlDoc->LoadFile();
|
||||||
|
@ -151,23 +159,35 @@ bool NppParameters::load(/*bool noUserPath*/)
|
||||||
strcpy(configPath, userPath);
|
strcpy(configPath, userPath);
|
||||||
PathAppend(configPath, "config.xml");
|
PathAppend(configPath, "config.xml");
|
||||||
|
|
||||||
if (!PathFileExists(configPath))
|
|
||||||
{
|
|
||||||
char srcConfigPath[MAX_PATH];
|
|
||||||
strcpy(srcConfigPath, nppPath);
|
|
||||||
PathAppend(srcConfigPath, "config.xml");
|
|
||||||
|
|
||||||
::CopyFile(srcConfigPath, configPath, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
_pXmlUserDoc = new TiXmlDocument(configPath);
|
_pXmlUserDoc = new TiXmlDocument(configPath);
|
||||||
loadOkay = _pXmlUserDoc->LoadFile();
|
loadOkay = _pXmlUserDoc->LoadFile();
|
||||||
if (!loadOkay)
|
if (!loadOkay)
|
||||||
{
|
{
|
||||||
::MessageBox(NULL, "Load config.xml failed!", "Configurator",MB_OK);
|
int res = ::MessageBox(NULL, "Load config.xml failed!\rDo you want to recover your config.xml?", "Configurator",MB_YESNO);
|
||||||
delete _pXmlUserDoc;
|
if (res ==IDYES)
|
||||||
_pXmlUserDoc = NULL;
|
{
|
||||||
isAllLaoded = false;
|
char srcConfigPath[MAX_PATH];
|
||||||
|
strcpy(srcConfigPath, nppPath);
|
||||||
|
PathAppend(srcConfigPath, "config.model.xml");
|
||||||
|
::CopyFile(srcConfigPath, configPath, FALSE);
|
||||||
|
|
||||||
|
loadOkay = _pXmlUserDoc->LoadFile();
|
||||||
|
if (!loadOkay)
|
||||||
|
{
|
||||||
|
::MessageBox(NULL, "Recover config.xml failed!", "Configurator",MB_OK);
|
||||||
|
delete _pXmlUserDoc;
|
||||||
|
_pXmlUserDoc = NULL;
|
||||||
|
isAllLaoded = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
getUserParametersFromXmlTree();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete _pXmlUserDoc;
|
||||||
|
_pXmlUserDoc = NULL;
|
||||||
|
isAllLaoded = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
getUserParametersFromXmlTree();
|
getUserParametersFromXmlTree();
|
||||||
|
@ -183,7 +203,7 @@ bool NppParameters::load(/*bool noUserPath*/)
|
||||||
{
|
{
|
||||||
char srcStylersPath[MAX_PATH];
|
char srcStylersPath[MAX_PATH];
|
||||||
strcpy(srcStylersPath, nppPath);
|
strcpy(srcStylersPath, nppPath);
|
||||||
PathAppend(srcStylersPath, "stylers.xml");
|
PathAppend(srcStylersPath, "stylers.model.xml");
|
||||||
|
|
||||||
::CopyFile(srcStylersPath, stylerPath, TRUE);
|
::CopyFile(srcStylersPath, stylerPath, TRUE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
CommandLine="copy ..\src\config.xml ..\bin\config.xml
copy ..\src\langs.xml ..\bin\langs.xml
copy ..\src\stylers.xml ..\bin\stylers.xml
copy ..\src\font\LINEDRAW.TTF ..\bin\LINEDRAW.TTF
copy ..\src\shortcuts.xml ..\bin\shortcuts.xml
copy ..\src\contextMenu.xml ..\bin\contextMenu.xml
"
|
CommandLine="copy ..\src\config.model.xml ..\bin\config.model.xml
copy ..\src\langs.model.xml ..\bin\langs.model.xml
copy ..\src\stylers.model.xml ..\bin\stylers.model.xml
copy ..\src\font\LINEDRAW.TTF ..\bin\LINEDRAW.TTF
copy ..\src\shortcuts.xml ..\bin\shortcuts.xml
copy ..\src\contextMenu.xml ..\bin\contextMenu.xml
"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
|
@ -573,11 +573,11 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\src\resource.h"
|
RelativePath="..\src\WinControls\Preference\resource.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\src\WinControls\Preference\resource.h"
|
RelativePath="..\src\resource.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
|
|
Loading…
Reference in New Issue