"Node does not exist or access denied.");
}
- if (!S_ISDIR(info.st_mode) & !S_ISREG(info.st_mode)) {
+ if (!S_ISDIR(info.st_mode) && !S_ISREG(info.st_mode)) {
ThrowMsg(Commons::PlatformException,
"Platform node is of unsupported type.");
}
NameList result;
errno = 0;
- struct dirent *entry = NULL;
- while ((entry = readdir(dir))) {
- if (!strncmp(entry->d_name, ".",
- 1) || !strncmp(entry->d_name, "..", 2))
+ int return_code;
+ struct dirent entry;
+ struct dirent *entry_result;
+ for (return_code = readdir_r(dir, &entry, &entry_result);
+ entry_result != NULL && return_code != 0;
+ return_code = readdir_r(dir, &entry, &entry_result)) {
+ if (!strncmp(entry.d_name, ".", 1) ||
+ !strncmp(entry.d_name, "..", 2))
{
continue;
}
- result.push_back(entry->d_name);
+ result.push_back(entry.d_name);
}
- if (errno != 0) {
+ if (return_code != 0 || errno != 0) {
ThrowMsg(Commons::PlatformException, "Error while reading directory.");
}
errno = 0;
NodeList result;
- struct dirent *entry = NULL;
- while ((entry = readdir(dir))) {
- if (!strncmp(entry->d_name, ".",
- 1) || !strncmp(entry->d_name, "..", 2))
+ int return_code;
+ struct dirent entry;
+ struct dirent *entry_result;
+ for (return_code = readdir_r(dir, &entry, &entry_result);
+ entry_result != NULL && return_code != 0;
+ return_code = readdir_r(dir, &entry, &entry_result)) {
+ if (!strncmp(entry.d_name, ".", 1) ||
+ !strncmp(entry.d_name, "..", 2))
{
continue;
}
Try {
Assert(m_path);
- INodePtr node = Node::resolve(*m_path + entry->d_name);
+ INodePtr node = Node::resolve(*m_path + entry.d_name);
node->setPermissions(getPermissions()); // inherit access rights
if (NodeFilterMatcher::match(node, filter)) {
result.push_back(node);
Catch(Commons::PlatformException) {}
}
- if (errno != 0) {
+ if (return_code != 0 || errno != 0) {
ThrowMsg(Commons::PlatformException, "Error while reading directory.");
}