From f0977e5cc9f89daf707032514ca712586376c312 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 24 Oct 2019 15:10:37 -0700 Subject: [PATCH] Print the found file entries after sorting --- alc/helpers.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/alc/helpers.cpp b/alc/helpers.cpp index 0e2dc067..bd0754b8 100644 --- a/alc/helpers.cpp +++ b/alc/helpers.cpp @@ -71,6 +71,7 @@ #include "alcmain.h" #include "almalloc.h" #include "alfstream.h" +#include "alspan.h" #include "alstring.h" #include "compat.h" #include "cpu_caps.h" @@ -325,18 +326,22 @@ static void DirectorySearch(const char *path, const char *ext, al::vectorsize(); + const auto base = results->cend() - results->cbegin(); + do { results->emplace_back(); std::string &str = results->back(); str = path; str += '\\'; str += wstr_to_utf8(fdata.cFileName); - TRACE(" got %s\n", str.c_str()); } while(FindNextFileW(hdl, &fdata)); FindClose(hdl); - std::sort(results->begin()+base, results->end()); + const al::span newlist{std::addressof(*(results->begin()+base)), + std::addressof(*results->end())}; + std::sort(newlist.begin(), newlist.end()); + for(const auto &name : newlist) + TRACE(" got %s\n", name.c_str()); } } @@ -516,7 +521,7 @@ static void DirectorySearch(const char *path, const char *ext, al::vectorcend() - results->cbegin(); + const auto base = results->cend() - results->cbegin(); const size_t extlen{strlen(ext)}; struct dirent *dirent; @@ -525,7 +530,7 @@ static void DirectorySearch(const char *path, const char *ext, al::vectord_name, ".") == 0 || strcmp(dirent->d_name, "..") == 0) continue; - size_t len{strlen(dirent->d_name)}; + const size_t len{strlen(dirent->d_name)}; if(len <= extlen) continue; if(al::strcasecmp(dirent->d_name+len-extlen, ext) != 0) continue; @@ -536,11 +541,14 @@ static void DirectorySearch(const char *path, const char *ext, al::vectord_name; - TRACE(" got %s\n", str.c_str()); } closedir(dir); - std::sort(results->begin()+base, results->end()); + const al::span newlist{std::addressof(*(results->begin()+base)), + std::addressof(*results->end())}; + std::sort(newlist.begin(), newlist.end()); + for(const auto &name : newlist) + TRACE(" got %s\n", name.c_str()); } }