summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/OGL/main.cpp
diff options
context:
space:
mode:
authorcomex <comexk@gmail.com>2014-11-15 15:46:40 -0500
committercomex <comexk@gmail.com>2015-05-28 19:14:42 -0400
commita225426510fc25316b3868e8764893dff284e77e (patch)
tree675c90e5057f2bbd5d2758d560845531e4dff303 /Source/Core/VideoBackends/OGL/main.cpp
parent6ff3fcee597663066c966a54ee51aab7fa166cd9 (diff)
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.
Diffstat (limited to 'Source/Core/VideoBackends/OGL/main.cpp')
-rw-r--r--Source/Core/VideoBackends/OGL/main.cpp45
1 files changed, 12 insertions, 33 deletions
diff --git a/Source/Core/VideoBackends/OGL/main.cpp b/Source/Core/VideoBackends/OGL/main.cpp
index c1a8b59280..464064ebac 100644
--- a/Source/Core/VideoBackends/OGL/main.cpp
+++ b/Source/Core/VideoBackends/OGL/main.cpp
@@ -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)