From d8818e2d322d96a0fdd3b24c0c0101e958f44231 Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Sat, 12 Oct 2024 11:19:49 -0400 Subject: [PATCH] Correctly store save data containing a colon in the key on windows, because someone thought it was a good idea for Sugarcube V3 saves to do this... --- FCHost/fchost/fchost_storage.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/FCHost/fchost/fchost_storage.cc b/FCHost/fchost/fchost_storage.cc index 666d9e6700f..9ee70b298d6 100644 --- a/FCHost/fchost/fchost_storage.cc +++ b/FCHost/fchost/fchost_storage.cc @@ -106,7 +106,15 @@ void FCHostPersistentStorage::load() readbuf[entrySize + 1] = readbuf[entrySize] = 0; // null terminate CefString val; val.FromString16(static_cast<const char16_t*>(static_cast<const void*>(readbuf.data()))); - storage.emplace(entry.path().filename().native(), CefV8Value::CreateString(val)); + auto sKey = entry.path().filename().native(); +#if defined(OS_WIN) + // put the fucking colon back in it + const size_t loc = sKey.find(L'#', 0); + if (loc != std::wstring::npos) { + sKey.replace(loc, static_cast<size_t>(1), L":"); + } +#endif + storage.emplace(sKey, CefV8Value::CreateString(val)); } } } @@ -115,7 +123,13 @@ void FCHostPersistentStorage::load() fs::path FCHostPersistentStorage::get_filename(const CefString& key) const { #if defined (OS_WIN) - return path / key.ToWString(); + std::wstring sKey = key.ToWString(); + // some fool decided to use a fucking colon as a key separator for SC V3 saves...can't have that in a filename on windows... + const size_t loc = sKey.find(L':', 0); + if (loc != std::wstring::npos) { + sKey.replace(loc, static_cast<size_t>(1), L"#"); + } + return path / sKey; #else return path / key.ToString(); #endif -- GitLab