]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Resolve PAL# 2058
authorribes <ribes>
Mon, 19 Mar 2012 10:40:43 +0000 (10:40 +0000)
committerribes <ribes>
Mon, 19 Mar 2012 10:40:43 +0000 (10:40 +0000)
Create a default catalog resources file if USER_CATALOG_RESOURCES_FILE
env variable is set on an unexisting file.

If we cannot create the file, we use the default catalog resource file

src/ResourcesManager/ResourcesManager.cxx

index c4a8cdd147e07a0dabbce6b30614984708d725e8..a5c3cd423f18c98eb32bc253e2cfc486f7db7b90 100644 (file)
@@ -96,8 +96,26 @@ ResourcesManager_cpp::ResourcesManager_cpp() throw(ResourcesException)
       _path_resources.push_back(user_file);
     }
     else {
-      default_catalog_resource = true;
+      default_catalog_resource = false;
       RES_INFOS("Warning: USER_CATALOG_RESOURCES_FILE is set and file cannot be found.")
+      RES_INFOS("Warning: That's why we try to create a new one.")
+      std::ofstream user_catalog_file;
+      user_catalog_file.open(user_file.c_str());
+      if (user_catalog_file.fail())
+      {
+        RES_INFOS("Error: cannot write in the user catalog resouces files");
+        RES_INFOS("Error: using default CatalogResources.xml file");
+        default_catalog_resource = true;
+      }
+      else
+      {
+        user_catalog_file << "<!-- File created by SALOME -->" << std::endl;
+        user_catalog_file << "<!DOCTYPE ResourcesCatalog>" << std::endl;
+        user_catalog_file << "<resources>" << std::endl;
+        user_catalog_file << "   <machine name=\"localhost\" hostname=\"localhost\" />" << std::endl;
+        user_catalog_file << "</resources>" << std::endl;
+        user_catalog_file.close();
+      }
     }
   }
   if (default_catalog_resource)