}
LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
- struct dirent* libdir;
+ int return_code;
+ struct dirent libdir;
+ struct dirent* result;
errno = 0;
std::list<std::string> pluginsPaths;
- while ((libdir = readdir(dir)) != 0) {
- if (strcmp(libdir->d_name, ".") == 0 ||
- strcmp(libdir->d_name, "..") == 0)
+ for (return_code = readdir_r(dir, &libdir, &result);
+ result != NULL && return_code != 0;
+ return_code = readdir_r(dir, &libdir, &result)) {
+ if (strcmp(libdir.d_name, ".") == 0 ||
+ strcmp(libdir.d_name, "..") == 0)
{
continue;
}
std::string path = PLUGIN_PATH;
path += "/";
- path += libdir->d_name;
+ path += libdir.d_name;
struct stat tmp;
pluginsPaths.push_back(path);
}
+ if (0 != return_code)
+ LogError("Error while reading directory.");
+
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << PLUGIN_PATH);
}