Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save paths in an agnostic format #121

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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