return LogAndCreateResult(ErrorCode::IO_ERR, "Node has been deleted from platform.");
}
- int err = 0;
- struct dirent entry = {0};
- struct dirent* result = nullptr;
+ errno = 0;
+ struct dirent* entry = nullptr;
NameList name_list;
- while ((0 == (err = readdir_r(dir, &entry, &result))) && result) {
- if (!strcmp(entry.d_name, ".") || !strncmp(entry.d_name, "..", 2)) {
+ while (nullptr != (entry = readdir(dir))) {
+ if (!strcmp(entry->d_name, ".") || !strncmp(entry->d_name, "..", 2)) {
continue;
}
- name_list.push_back(entry.d_name);
+ name_list.push_back(entry->d_name);
}
if (closedir(dir) != 0) {
return LogAndCreateResult(ErrorCode::IO_ERR, "Could not close platform node.");
}
- if (0 != err) {
+ if (0 != errno) {
return LogAndCreateResult(ErrorCode::IO_ERR, "Error while reading directory.");
}
return LogAndCreateResult(ErrorCode::IO_ERR, "Node has been deleted from platform.");
}
- int err = 0;
- struct dirent entry = {0};
- struct dirent* result = nullptr;
+ errno = 0;
+ struct dirent* entry = nullptr;
NodeList node_list;
- while ((0 == (err = readdir_r(dir, &entry, &result))) && result) {
- if (!strcmp(entry.d_name, ".") || !strncmp(entry.d_name, "..", 2)) {
+ while (nullptr != (entry = readdir(dir))) {
+ if (!strcmp(entry->d_name, ".") || !strncmp(entry->d_name, "..", 2)) {
continue;
}
NodePtr node;
- Node::resolve(*m_path + entry.d_name, &node);
+ Node::resolve(*m_path + entry->d_name, &node);
node->setPermissions(getPermissions()); // inherit access rights
node_list.push_back(node);
}
return LogAndCreateResult(ErrorCode::IO_ERR, "Could not close platform node.");
}
- if (0 != err) {
+ if (0 != errno) {
SLoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms);
return LogAndCreateResult(ErrorCode::IO_ERR, "Error while reading directory.");
}
SLoggerE("File %s", path->getFullPath().c_str());
return LogAndCreateResult(ErrorCode::IO_ERR, "Node does not exist or access denied.");
}
- struct dirent entry = {0};
- struct dirent* result = nullptr;
+ struct dirent* entry = nullptr;
PlatformResult platform_result(ErrorCode::NO_ERROR);
- while ((0 == (readdir_r(dir, &entry, &result))) && result) {
- if (!strcmp(entry.d_name, ".") || !strncmp(entry.d_name, "..", 2)) {
+ while (nullptr != (entry = readdir(dir))) {
+ if (!strcmp(entry->d_name, ".") || !strncmp(entry->d_name, "..", 2)) {
continue;
}
- PathPtr subPath = *path + entry.d_name;
+ PathPtr subPath = *path + entry->d_name;
struct stat info;
memset(&info, 0, sizeof(struct stat));
if (lstat(subPath->getFullPath().c_str(), &info) == 0) {
SCOPE_EXIT {
(void)closedir(dp);
};
- struct dirent entry;
- struct dirent* result = nullptr;
- while (0 == (status = readdir_r(dp, &entry, &result)) && result != nullptr) {
- if (strcmp(result->d_name, ".") == 0 || strcmp(result->d_name, "..") == 0)
+ errno = 0;
+ struct dirent* entry = nullptr;
+ while (nullptr != (entry = readdir(dp))) {
+ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
continue;
std::string oldLocation = originPath + std::string("/")
- + std::string(result->d_name);
+ + std::string(entry->d_name);
std::string newLocation = destPath + std::string("/")
- + std::string(result->d_name);
+ + std::string(entry->d_name);
FilesystemError fstatus = FilesystemError::None;
- if (result->d_type == DT_DIR) {
+ if (entry->d_type == DT_DIR) {
fstatus = copyDirectory(oldLocation, newLocation);
- } else if (result->d_type == DT_REG) {
+ } else if (entry->d_type == DT_REG) {
fstatus = copyFile(oldLocation, newLocation);
}
if (fstatus != FilesystemError::None) {
return fstatus;
}
}
- if (status != 0) {
+
+ if (0 != errno) {
LoggerE("error occured");
return FilesystemError::Other;
}
std::vector < std::string > fileList;
DIR* dp = nullptr;
- struct dirent entry;
- struct dirent* result = nullptr;
- int status = 0;
+ struct dirent* entry = nullptr;
dp = opendir(path.c_str());
if (dp != NULL) {
- while ((status = readdir_r(dp, &entry, &result)) == 0 && result != nullptr) {
- if (strcmp(result->d_name, ".") != 0 && strcmp(result->d_name, "..") != 0)
- fileList.push_back(path + "/" + std::string(result->d_name));
+ errno = 0;
+ while (nullptr != (entry = readdir(dp))) {
+ if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0)
+ fileList.push_back(path + "/" + std::string(entry->d_name));
}
(void) closedir(dp);
- if (status == 0) {
+ if (0 == errno) {
success_cb(fileList);
} else {
LoggerE("error occured");