better code for getDirectoryEntries

This commit is contained in:
wheremyfoodat 2023-11-08 12:04:26 +02:00 committed by georgemoralis
parent 1ced777f20
commit e35efb55a2
1 changed files with 6 additions and 6 deletions

View File

@ -1,4 +1,5 @@
#include "common/fs_file.h"
#include <filesystem>
namespace Common::FS {
@ -66,17 +67,16 @@ std::vector<DirEntry> File::getDirectoryEntries(const std::string& path) {
std::vector<DirEntry> files;
for (const auto& entry : std::filesystem::directory_iterator(curpath)) {
if (std::filesystem::is_regular_file( entry.path().string())) {
DirEntry e = {};
if (std::filesystem::is_regular_file(entry.path().string())) {
e.name = entry.path().filename().string();
e.isFile = true;
files.push_back(e);
} else {
DirEntry e = {};
e.name = entry.path().filename().string() + "/"; //hmmm not sure if it has to be like this...
e.name = entry.path().filename().string() + "/"; // hmmm not sure if it has to be like this...
e.isFile = false;
files.push_back(e);
}
files.push_back(e);
}
return files;