1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

Use std::filestytem

Signed-off-by: Pascal Bauer <pascal.bauer@rwth-aachen.de>
This commit is contained in:
Pascal Bauer 2024-10-09 16:39:49 +02:00 committed by Niklas Eiling
parent 7e7b9e4918
commit 00ac2ee60c

View file

@ -368,20 +368,12 @@ void write_to_file(std::string data, const std::filesystem::path file) {
}
}
std::vector<std::string> read_names_in_directory(const std::string &name) {
DIR *directory = opendir(name.c_str());
struct dirent *dp;
std::vector<std::string>
read_names_in_directory(const std::filesystem::path &dir_path) {
std::vector<std::string> names;
dp = readdir(directory);
while (dp != NULL) {
auto name = std::string(dp->d_name);
if (name != "." && name != "..") {
names.push_back(name);
}
dp = readdir(directory);
for (auto const &dir_entry : std::filesystem::directory_iterator{dir_path}) {
names.push_back(dir_entry.path().filename());
}
closedir(directory);
return names;
}