prompt with error messageboxes for problems when reading init files

svn path=/trunk/; revision=9435
This commit is contained in:
Martin Fuchs 2004-05-18 12:38:39 +00:00
parent 9c4dd6241a
commit 4b62bbcaa8
3 changed files with 22 additions and 7 deletions

View file

@ -82,8 +82,13 @@ void ExplorerGlobals::read_persistent()
_cfg_dir.printf(TEXT("%s\\ReactOS"), (LPCTSTR)SpecialFolderFSPath(CSIDL_APPDATA,0)); _cfg_dir.printf(TEXT("%s\\ReactOS"), (LPCTSTR)SpecialFolderFSPath(CSIDL_APPDATA,0));
_cfg_path.printf(TEXT("%s\\ros-explorer-cfg.xml"), _cfg_dir.c_str()); _cfg_path.printf(TEXT("%s\\ros-explorer-cfg.xml"), _cfg_dir.c_str());
if (!_cfg.read(_cfg_path)) if (!_cfg.read(_cfg_path)) {
if (_cfg._last_error != XML_ERROR_NO_ELEMENTS)
MessageBox(g_Globals._hwndDesktop, String(_cfg._last_error_msg.c_str()),
TEXT("ROS Explorer - reading user settings"), MB_OK);
_cfg.read(TEXT("explorer-cfg-template.xml")); _cfg.read(TEXT("explorer-cfg-template.xml"));
}
// read bookmarks // read bookmarks
_favorites_path.printf(TEXT("%s\\ros-explorer-bookmarks.xml"), _cfg_dir.c_str()); _favorites_path.printf(TEXT("%s\\ros-explorer-bookmarks.xml"), _cfg_dir.c_str());

View file

@ -427,7 +427,11 @@ bool Favorites::read(LPCTSTR path)
XMLDoc xbel; XMLDoc xbel;
if (!xbel.read(path)) if (!xbel.read(path))
return false; if (xbel._last_error == XML_ERROR_NO_ELEMENTS)
return false;
else
MessageBox(g_Globals._hwndDesktop, String(xbel._last_error_msg.c_str()),
TEXT("ROS Explorer - reading bookmark file"), MB_OK);
const_XMLPos pos(&xbel); const_XMLPos pos(&xbel);

View file

@ -1232,6 +1232,7 @@ struct XMLReader
return out.str(); return out.str();
} }
XML_Error get_error_code() {return XML_GetErrorCode(_parser);}
std::string get_error_string() const; std::string get_error_string() const;
protected: protected:
@ -1276,12 +1277,14 @@ struct XMLHeader : public std::string
struct XMLDoc : public XMLNode struct XMLDoc : public XMLNode
{ {
XMLDoc() XMLDoc()
: XMLNode("") : XMLNode(""),
_last_error(XML_ERROR_NONE)
{ {
} }
XMLDoc(LPCTSTR path) XMLDoc(LPCTSTR path)
: XMLNode("") : XMLNode(""),
_last_error(XML_ERROR_NONE)
{ {
read(path); read(path);
} }
@ -1297,7 +1300,8 @@ struct XMLDoc : public XMLNode
out << reader.get_position() << " " << reader.get_error_string(); out << reader.get_position() << " " << reader.get_error_string();
_last_error = out.str(); _last_error = reader.get_error_code();
_last_error_msg = out.str();
} }
return in; return in;
@ -1315,7 +1319,8 @@ struct XMLDoc : public XMLNode
out << path << reader.get_position() << " " << reader.get_error_string(); out << path << reader.get_position() << " " << reader.get_error_string();
_last_error = out.str(); _last_error = reader.get_error_code();
_last_error_msg = out.str();
} }
return status != XML_STATUS_ERROR; return status != XML_STATUS_ERROR;
@ -1352,7 +1357,8 @@ struct XMLDoc : public XMLNode
write_formating(out); write_formating(out);
} }
std::string _last_error; XML_Error _last_error;
std::string _last_error_msg;
}; };