dmuratshin 9 years ago
parent
commit
91cb8d7682
2 changed files with 20 additions and 8 deletions
  1. 16 7
      oxygine/src/res/Resources.cpp
  2. 4 1
      oxygine/src/res/Resources.h

+ 16 - 7
oxygine/src/res/Resources.cpp

@@ -127,6 +127,11 @@ namespace oxygine
         __freeName();
         __freeName();
     }
     }
 
 
+	bool Resources::isEmpty() const
+	{
+		return _docs.empty();
+	}
+
     void Resources::updateName(const std::string& filename)
     void Resources::updateName(const std::string& filename)
     {
     {
         char head[256];
         char head[256];
@@ -167,7 +172,7 @@ namespace oxygine
     };
     };
 
 
 
 
-    void Resources::loadXML(const std::string& xmlFile, const ResourcesLoadOptions& opt)
+    bool Resources::loadXML(const std::string& xmlFile, const ResourcesLoadOptions& opt)
     {
     {
         _name = xmlFile;
         _name = xmlFile;
         _loadCounter = opt._loadCompletely ? 1 : 0;
         _loadCounter = opt._loadCompletely ? 1 : 0;
@@ -175,7 +180,15 @@ namespace oxygine
 
 
         FS_LOG("step0");
         FS_LOG("step0");
         file::buffer fb;
         file::buffer fb;
-        file::read(xmlFile, fb);
+        int sz = file::read(xmlFile, fb);
+
+
+		if (!sz)
+		{
+			log::error("can't load xml file: '%s'", xmlFile.c_str());
+			OX_ASSERT(!"can't find xml file");
+			return false;
+		}
 
 
         FS_LOG("step1");
         FS_LOG("step1");
 
 
@@ -207,11 +220,6 @@ namespace oxygine
                 doc_meta.load_buffer_inplace(&fb_meta.data[0], fb_meta.data.size());
                 doc_meta.load_buffer_inplace(&fb_meta.data[0], fb_meta.data.size());
         }
         }
 
 
-        if (!fb.data.size())
-        {
-            OX_ASSERT(fb.data.size() && "can't find xml file");
-            return;
-        }
 
 
         pugi::xml_document* doc = new pugi::xml_document();
         pugi::xml_document* doc = new pugi::xml_document();
         _docs.push_back(doc);
         _docs.push_back(doc);
@@ -279,6 +287,7 @@ namespace oxygine
         }
         }
 
 
         FS_LOG("xml loaded");
         FS_LOG("xml loaded");
+		return true;
     }
     }
 
 
     void Resources::collect(resources& r)
     void Resources::collect(resources& r)

+ 4 - 1
oxygine/src/res/Resources.h

@@ -78,7 +78,7 @@ namespace oxygine
         @param xml file paths
         @param xml file paths
         @param options
         @param options
         */
         */
-        void loadXML(const std::string& xmlFile, const ResourcesLoadOptions& opt = ResourcesLoadOptions());
+        bool loadXML(const std::string& xmlFile, const ResourcesLoadOptions& opt = ResourcesLoadOptions());
 
 
         /**Adds Resource*/
         /**Adds Resource*/
         void add(Resource* r, bool accessByShortenID = false);
         void add(Resource* r, bool accessByShortenID = false);
@@ -92,6 +92,9 @@ namespace oxygine
         /**Completely deletes all loaded resources*/
         /**Completely deletes all loaded resources*/
         void free();
         void free();
 
 
+		/**Does it have any loaded xmls*/
+		bool isEmpty() const;
+
         /** get resource by id, no case sensitive
         /** get resource by id, no case sensitive
         @param resource id
         @param resource id
         */
         */