From 7cdc8fbadc08eca6377c9b9bf6c24a342b8cbc96 Mon Sep 17 00:00:00 2001 From: ribes Date: Tue, 12 Jul 2011 13:49:45 +0000 Subject: [PATCH] Fix Bug with USER_CATALOG_RESOURCES_FILE is set with a non-existing file --- src/ResourcesManager/ResourcesManager.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index d6627d4e6..c4a8cdd14 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -84,13 +84,23 @@ ResourcesManager_cpp::ResourcesManager_cpp() throw(ResourcesException) _resourceManagerMap["best"]=&altcycl; _resourceManagerMap[""]=&altcycl; + bool default_catalog_resource = true; if (getenv("USER_CATALOG_RESOURCES_FILE") != 0) { + default_catalog_resource = false; std::string user_file(""); user_file = getenv("USER_CATALOG_RESOURCES_FILE"); - _path_resources.push_back(user_file); + std::ifstream ifile(user_file.c_str(), std::ifstream::in ); + if (ifile) { + // The file exists, and is open for input + _path_resources.push_back(user_file); + } + else { + default_catalog_resource = true; + RES_INFOS("Warning: USER_CATALOG_RESOURCES_FILE is set and file cannot be found.") + } } - else + if (default_catalog_resource) { std::string default_file(""); if (getenv("APPLI") != 0) -- 2.39.2