mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Rewrite FileSearch and improve ScanDirectoryTree.
- FileSearch is now just one function, and it converts the original glob into a regex on all platforms rather than relying on native Windows pattern matching on there and a complete hack elsewhere. It now supports recursion out of the box rather than manually expanding into a full list of directories in multiple call sites. - This adds a GCC >= 4.9 dependency due to older versions having outright broken <regex>. MSVC is fine with it. - ScanDirectoryTree returns the parent entry rather than filling parts of it in via reference. The count is now stored in the entry like it was for subdirectories. - .glsl file search is now done with DoFileSearch. - IOCTLV_READ_DIR now uses ScanDirectoryTree directly and sorts the results after replacements for better determinism.
This commit is contained in:
@ -38,9 +38,11 @@ Make AA apply instantly during gameplay if possible
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdarg>
|
||||
#include <regex>
|
||||
|
||||
#include "Common/Atomic.h"
|
||||
#include "Common/CommonPaths.h"
|
||||
#include "Common/FileSearch.h"
|
||||
#include "Common/Thread.h"
|
||||
#include "Common/Logging/LogManager.h"
|
||||
|
||||
@ -95,39 +97,16 @@ std::string VideoBackend::GetDisplayName() const
|
||||
return "OpenGL";
|
||||
}
|
||||
|
||||
static void GetShaders(std::vector<std::string> &shaders, const std::string &sub_dir = "")
|
||||
static std::vector<std::string> GetShaders(const std::string &sub_dir = "")
|
||||
{
|
||||
std::set<std::string> already_found;
|
||||
|
||||
shaders.clear();
|
||||
const std::string directories[] = {
|
||||
std::vector<std::string> paths = DoFileSearch({"*.glsl"}, {
|
||||
File::GetUserPath(D_SHADERS_IDX) + sub_dir,
|
||||
File::GetSysDirectory() + SHADERS_DIR DIR_SEP + sub_dir,
|
||||
};
|
||||
for (auto& directory : directories)
|
||||
{
|
||||
if (!File::IsDirectory(directory))
|
||||
continue;
|
||||
|
||||
File::FSTEntry entry;
|
||||
File::ScanDirectoryTree(directory, entry);
|
||||
for (auto& file : entry.children)
|
||||
{
|
||||
std::string name = file.virtualName;
|
||||
if (name.size() < 5)
|
||||
continue;
|
||||
if (strcasecmp(name.substr(name.size() - 5).c_str(), ".glsl"))
|
||||
continue;
|
||||
|
||||
name = name.substr(0, name.size() - 5);
|
||||
if (already_found.find(name) != already_found.end())
|
||||
continue;
|
||||
|
||||
already_found.insert(name);
|
||||
shaders.push_back(name);
|
||||
}
|
||||
}
|
||||
std::sort(shaders.begin(), shaders.end());
|
||||
File::GetSysDirectory() + SHADERS_DIR DIR_SEP + sub_dir
|
||||
});
|
||||
std::vector<std::string> result;
|
||||
for (std::string path : paths)
|
||||
result.push_back(std::regex_replace(path, std::regex("^.*/(.*)\\.glsl$"), "$1"));
|
||||
return result;
|
||||
}
|
||||
|
||||
static void InitBackendInfo()
|
||||
@ -146,8 +125,8 @@ static void InitBackendInfo()
|
||||
g_Config.backend_info.AAModes.assign(caamodes, caamodes + sizeof(caamodes)/sizeof(*caamodes));
|
||||
|
||||
// pp shaders
|
||||
GetShaders(g_Config.backend_info.PPShaders);
|
||||
GetShaders(g_Config.backend_info.AnaglyphShaders, std::string(ANAGLYPH_DIR DIR_SEP));
|
||||
g_Config.backend_info.PPShaders = GetShaders("");
|
||||
g_Config.backend_info.AnaglyphShaders = GetShaders(ANAGLYPH_DIR DIR_SEP);
|
||||
}
|
||||
|
||||
void VideoBackend::ShowConfig(void *_hParent)
|
||||
|
Reference in New Issue
Block a user