Skip to content

Commit eee7eb7

Browse files
committed
Search the app-local directories separately first
1 parent 09de2bc commit eee7eb7

File tree

3 files changed

+38
-15
lines changed

3 files changed

+38
-15
lines changed

core/helpers.cpp

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,22 @@ struct CoTaskMemDeleter {
137137

138138
} // namespace
139139

140-
std::vector<std::string> SearchDataFiles(const std::string_view ext, const std::string_view subdir)
140+
auto SearchDataFiles(const std::string_view ext) -> std::vector<std::string>
141+
{
142+
auto srchlock = std::lock_guard{gSearchLock};
143+
144+
/* Search the app-local directory. */
145+
auto results = std::vector<std::string>{};
146+
if(auto localpath = al::getenv(L"ALSOFT_LOCAL_PATH"))
147+
DirectorySearch(*localpath, ext, &results);
148+
else if(auto curpath = std::filesystem::current_path(); !curpath.empty())
149+
DirectorySearch(curpath, ext, &results);
150+
151+
return results;
152+
}
153+
154+
auto SearchDataFiles(const std::string_view ext, const std::string_view subdir)
155+
-> std::vector<std::string>
141156
{
142157
std::lock_guard<std::mutex> srchlock{gSearchLock};
143158

@@ -150,12 +165,6 @@ std::vector<std::string> SearchDataFiles(const std::string_view ext, const std::
150165
return results;
151166
}
152167

153-
/* Search the app-local directory. */
154-
if(auto localpath = al::getenv(L"ALSOFT_LOCAL_PATH"))
155-
DirectorySearch(*localpath, ext, &results);
156-
else if(auto curpath = std::filesystem::current_path(); !curpath.empty())
157-
DirectorySearch(curpath, ext, &results);
158-
159168
#if !defined(ALSOFT_UWP) && !defined(_GAMING_XBOX)
160169
/* Search the local and global data dirs. */
161170
for(const auto &folderid : std::array{FOLDERID_RoamingAppData, FOLDERID_ProgramData})
@@ -295,7 +304,22 @@ const PathNamePair &GetProcBinary()
295304
return procbin;
296305
}
297306

298-
std::vector<std::string> SearchDataFiles(const std::string_view ext, const std::string_view subdir)
307+
auto SearchDataFiles(const std::string_view ext) -> std::vector<std::string>
308+
{
309+
auto srchlock = std::lock_guard{gSearchLock};
310+
311+
/* Search the app-local directory. */
312+
auto results = std::vector<std::string>{};
313+
if(auto localpath = al::getenv("ALSOFT_LOCAL_PATH"))
314+
DirectorySearch(*localpath, ext, &results);
315+
else if(auto curpath = std::filesystem::current_path(); !curpath.empty())
316+
DirectorySearch(curpath, ext, &results);
317+
318+
return results;
319+
}
320+
321+
auto SearchDataFiles(const std::string_view ext, const std::string_view subdir)
322+
-> std::vector<std::string>
299323
{
300324
std::lock_guard<std::mutex> srchlock{gSearchLock};
301325

@@ -307,12 +331,6 @@ std::vector<std::string> SearchDataFiles(const std::string_view ext, const std::
307331
return results;
308332
}
309333

310-
/* Search the app-local directory. */
311-
if(auto localpath = al::getenv("ALSOFT_LOCAL_PATH"))
312-
DirectorySearch(*localpath, ext, &results);
313-
else if(auto curpath = std::filesystem::current_path(); !curpath.empty())
314-
DirectorySearch(curpath, ext, &results);
315-
316334
/* Search local data dir */
317335
if(auto datapath = al::getenv("XDG_DATA_HOME"))
318336
DirectorySearch(std::filesystem::path{*datapath}/path, ext, &results);

core/helpers.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ inline bool AllowRTTimeLimit{true};
1919

2020
void SetRTPriority();
2121

22-
std::vector<std::string> SearchDataFiles(const std::string_view ext, const std::string_view subdir);
22+
auto SearchDataFiles(const std::string_view ext) -> std::vector<std::string>;
23+
auto SearchDataFiles(const std::string_view ext, const std::string_view subdir)
24+
-> std::vector<std::string>;
2325

2426
#endif /* CORE_HELPERS_H */

core/hrtf.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,9 @@ std::vector<std::string> EnumerateHrtf(std::optional<std::string> pathopt)
12101210
std::lock_guard<std::mutex> enumlock{EnumeratedHrtfLock};
12111211
EnumeratedHrtfs.clear();
12121212

1213+
for(const auto &fname : SearchDataFiles(".mhr"sv))
1214+
AddFileEntry(fname);
1215+
12131216
bool usedefaults{true};
12141217
if(pathopt)
12151218
{

0 commit comments

Comments
 (0)