From e35efb55a299d015f17020c1891ef033dc4a94ae Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Wed, 8 Nov 2023 12:04:26 +0200 Subject: [PATCH] better code for getDirectoryEntries --- src/common/fs_file.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/fs_file.cpp b/src/common/fs_file.cpp index fb51309c..716e0e1e 100644 --- a/src/common/fs_file.cpp +++ b/src/common/fs_file.cpp @@ -1,4 +1,5 @@ #include "common/fs_file.h" + #include namespace Common::FS { @@ -58,7 +59,7 @@ u64 File::tell() const { return -1; } -std::vector File::getDirectoryEntries(const std::string& path) { +std::vector File::getDirectoryEntries(const std::string& path) { std::string curpath = path; if (!curpath.ends_with("/")) { curpath = std::string(curpath + "/"); @@ -66,17 +67,16 @@ std::vector File::getDirectoryEntries(const std::string& path) { std::vector files; for (const auto& entry : std::filesystem::directory_iterator(curpath)) { - if (std::filesystem::is_regular_file( entry.path().string())) { - DirEntry e = {}; + 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;