Adds verbose message when a resource is not found.

Fix #1309
This commit is contained in:
Felipe Zimmerle
2017-05-02 13:38:41 -03:00
parent 77a658c7cd
commit c97db2f361
10 changed files with 906 additions and 831 deletions

View File

@@ -59,21 +59,26 @@ double cpu_seconds(void) {
std::string find_resource(const std::string& resource,
const std::string& config) {
const std::string& config, std::string *err) {
std::ifstream *iss;
err->assign("Looking at: ");
// Trying absolute or relative to the current dir.
iss = new std::ifstream(resource, std::ios::in);
if (iss->is_open()) {
iss->close();
delete iss;
return resource;
} else {
err->append("'" + resource + "', ");
}
delete iss;
// What about `*' ?
if (utils::expandEnv(resource, 0).size() > 1) {
return resource;
} else {
err->append("'" + resource + "', ");
}
// Trying the same path of the configuration file.
@@ -83,12 +88,16 @@ std::string find_resource(const std::string& resource,
iss->close();
delete iss;
return f;
} else {
err->append("'" + f + "', ");
}
delete iss;
// What about `*' ?
if (utils::expandEnv(f, 0).size() > 1) {
return f;
} else {
err->append("'" + f + "'.");
}
return std::string("");

View File

@@ -29,7 +29,8 @@ namespace utils {
double cpu_seconds(void);
std::string find_resource(const std::string& file, const std::string& param);
std::string find_resource(const std::string& file, const std::string& param,
std::string *err);
std::string get_path(const std::string& file);
std::list<std::string> expandEnv(const std::string& var, int flags);
bool createDir(std::string dir, int mode, std::string *error);