prompt with error messageboxes for problems when reading init files
authorMartin Fuchs <fuchs.martin@gmail.com>
Tue, 18 May 2004 12:38:39 +0000 (12:38 +0000)
committerMartin Fuchs <fuchs.martin@gmail.com>
Tue, 18 May 2004 12:38:39 +0000 (12:38 +0000)
svn path=/trunk/; revision=9435

reactos/subsys/system/explorer/explorer.cpp
reactos/subsys/system/explorer/taskbar/favorites.cpp
reactos/subsys/system/explorer/utility/xmlstorage.h

index e415bb2..fb55a7c 100644 (file)
@@ -82,8 +82,13 @@ void ExplorerGlobals::read_persistent()
        _cfg_dir.printf(TEXT("%s\\ReactOS"), (LPCTSTR)SpecialFolderFSPath(CSIDL_APPDATA,0));
        _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"));
+       }
 
         // read bookmarks
        _favorites_path.printf(TEXT("%s\\ros-explorer-bookmarks.xml"), _cfg_dir.c_str());
index 330cad2..c10af85 100644 (file)
@@ -427,7 +427,11 @@ bool Favorites::read(LPCTSTR path)
        XMLDoc xbel;
 
        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);
 
index 7af85de..910f8bb 100644 (file)
@@ -1232,6 +1232,7 @@ struct XMLReader
                return out.str();
        }
 
+       XML_Error       get_error_code() {return XML_GetErrorCode(_parser);}
        std::string get_error_string() const;
 
 protected:
@@ -1276,12 +1277,14 @@ struct XMLHeader : public std::string
 struct XMLDoc : public XMLNode
 {
        XMLDoc()
-        :      XMLNode("")
+        :      XMLNode(""),
+               _last_error(XML_ERROR_NONE)
        {
        }
 
        XMLDoc(LPCTSTR path)
-        :      XMLNode("")
+        :      XMLNode(""),
+               _last_error(XML_ERROR_NONE)
        {
                read(path);
        }
@@ -1297,7 +1300,8 @@ struct XMLDoc : public XMLNode
 
                        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;
@@ -1315,7 +1319,8 @@ struct XMLDoc : public XMLNode
 
                        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;
@@ -1352,7 +1357,8 @@ struct XMLDoc : public XMLNode
                write_formating(out);
        }
 
-       std::string     _last_error;
+       XML_Error       _last_error;
+       std::string     _last_error_msg;
 };