From 156205d4772440675ac2cae40e806b8b1ba1e452 Mon Sep 17 00:00:00 2001 From: ribes Date: Mon, 19 Mar 2012 10:40:43 +0000 Subject: [PATCH] Resolve PAL# 2058 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 | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index c4a8cdd14..a5c3cd423 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -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 << "" << std::endl; + user_catalog_file << "" << std::endl; + user_catalog_file << "" << std::endl; + user_catalog_file << " " << std::endl; + user_catalog_file << "" << std::endl; + user_catalog_file.close(); + } } } if (default_catalog_resource) -- 2.39.2