Skip to content

Commit

Permalink
Save paths in an agnostic format
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfd committed Dec 15, 2023
1 parent 338d946 commit 5e4cee4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions plugins/common/plugin/NativeHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/common/plugin/NativeHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
4 changes: 2 additions & 2 deletions plugins/vst/SfizzVstState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down

0 comments on commit 5e4cee4

Please sign in to comment.