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:
parent
7e7b9e4918
commit
00ac2ee60c
1 changed files with 4 additions and 12 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue