From b1d1f2aa06f4bf7d0a7f5a151c285a0fea0db965 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sat, 16 Apr 2022 02:01:24 +0200 Subject: Common/StringUtil: Add convenience function for converting paths to use forward slashes on Windows. --- Source/Core/Common/StringUtil.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'Source/Core/Common/StringUtil.cpp') diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index a752ab0e10..c498e261fd 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -335,6 +335,23 @@ bool SplitPath(std::string_view full_path, std::string* path, std::string* filen return true; } +void UnifyPathSeparators(std::string& path) +{ +#ifdef _WIN32 + for (char& c : path) + { + if (c == '\\') + c = '/'; + } +#endif +} + +std::string WithUnifiedPathSeparators(std::string path) +{ + UnifyPathSeparators(path); + return path; +} + std::string PathToFileName(std::string_view path) { std::string file_name, extension; -- cgit v1.2.3