Merge branch 'master' of github.com:john30/ebusd

This commit is contained in:
john30
2015-03-13 00:15:26 +01:00
+17 -16
View File
@@ -442,32 +442,33 @@ static result_t readConfigFiles(const string path, const string extension, DataF
if (dir == NULL) if (dir == NULL)
return RESULT_ERR_NOTFOUND; return RESULT_ERR_NOTFOUND;
dirent* d = readdir(dir); dirent* d;
while (d != NULL) { while ((d = readdir(dir)) != NULL) {
if (d->d_type == DT_DIR) { string fn = d->d_name;
string fn = d->d_name;
if (fn != "." && fn != "..") { if (fn == "." || fn == "..")
const string p = path + "/" + d->d_name; continue;
result_t result = readConfigFiles(p, extension, templates, messages, verbose);
if (result != RESULT_OK) const string p = path + "/" + d->d_name;
return result; struct stat stat_buf;
}
if (stat(p.c_str(), &stat_buf) != 0)
continue;
if (S_ISDIR(stat_buf.st_mode)) {
result_t result = readConfigFiles(p, extension, templates, messages, verbose);
if (result != RESULT_OK)
return result;
} }
else if (d->d_type == DT_REG || d->d_type == DT_LNK) { else if (S_ISREG(stat_buf.st_mode)) {
string fn = d->d_name;
if (fn.find(extension, (fn.length() - extension.length())) != string::npos if (fn.find(extension, (fn.length() - extension.length())) != string::npos
&& fn != "_templates" + extension) { && fn != "_templates" + extension) {
const string p = path + "/" + d->d_name;
result_t result = messages->readFromFile(p, templates, verbose); result_t result = messages->readFromFile(p, templates, verbose);
if (result != RESULT_OK) if (result != RESULT_OK)
return result; return result;
} }
} }
d = readdir(dir);
} }
closedir(dir); closedir(dir);