Save paths in an agnostic format

This commit is contained in:
Paul Fd 2023-12-06 22:23:19 +01:00 committed by Paul Ferrand
parent 338d946b9a
commit 5e4cee48c4
3 changed files with 8 additions and 7 deletions

View file

@ -14,10 +14,11 @@
#if defined(_WIN32)
const fs::path toPlatformAgnosticPath(std::string& filePath)
const fs::path toPlatformAgnosticPath(const std::string& filePath)
{
std::replace(filePath.begin(), filePath.end(), '\\', '/');
return fs::u8path(filePath);
std::string p { filePath };
std::replace(p.begin(), p.end(), '\\', '/');
return fs::u8path(p);
}
const fs::path fromPlatformAgnosticPath(const char *filePath)
{
@ -26,7 +27,7 @@ const fs::path fromPlatformAgnosticPath(const char *filePath)
return fs::u8path(p);
}
#else
const fs::path toPlatformAgnosticPath(std::string& filePath)
const fs::path toPlatformAgnosticPath(const std::string& filePath)
{
return fs::u8path(filePath);
}

View file

@ -13,7 +13,7 @@
const fs::path& getUserDocumentsDirectory();
const fs::path toPlatformAgnosticPath(std::string& filePath);
const fs::path toPlatformAgnosticPath(const std::string& filePath);
const fs::path fromPlatformAgnosticPath(const char *filePath);
#if !defined(_WIN32) && !defined(__APPLE__)

View file

@ -122,7 +122,7 @@ tresult SfizzVstState::store(IBStream* state) const
if (!s.writeInt64u(currentStateVersion))
return kResultFalse;
if (!s.writeStr8(sfzFile.c_str()))
if (!s.writeStr8(toPlatformAgnosticPath(sfzFile).string().c_str()))
return kResultFalse;
if (!s.writeFloat(volume))
@ -137,7 +137,7 @@ tresult SfizzVstState::store(IBStream* state) const
if (!s.writeInt32(preloadSize))
return kResultFalse;
if (!s.writeStr8(scalaFile.c_str()))
if (!s.writeStr8(toPlatformAgnosticPath(scalaFile).string().c_str()))
return kResultFalse;
if (!s.writeInt32(scalaRootKey))