gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit 2e5fabe0c5bad861f4f10884f5a8ddf2ad13cec1
parent e53cf9df239f934d0b12a78e99af1fd005a1d469
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Sat, 26 Oct 2024 23:13:21 +0200

validatePath ensures that only native path separators are used

Diffstat:
Msource/synthLib/os.cpp | 21++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/source/synthLib/os.cpp b/source/synthLib/os.cpp @@ -40,7 +40,14 @@ namespace synthLib { - std::string getModulePath(bool _stripPluginComponentFolders/* = true*/) +#ifdef _WIN32 + constexpr char g_nativePathSeparator = '\\'; +#else + constexpr char g_nativePathSeparator = '/'; +#endif + constexpr char g_otherPathSeparator = g_nativePathSeparator == '\\' ? '/' : '\\'; + + std::string getModulePath(bool _stripPluginComponentFolders/* = true*/) { std::string path; #ifdef _WIN32 @@ -138,9 +145,17 @@ namespace synthLib { if(_path.empty()) return _path; - if(_path.back() == '/' || _path.back() == '\\') + + for (char& ch : _path) + { + if(ch == g_otherPathSeparator) + ch = g_nativePathSeparator; + } + + if(_path.back() == g_nativePathSeparator) return _path; - _path += '/'; + + _path += g_nativePathSeparator; return _path; }