Skip to content
Snippets Groups Projects
Commit d8818e2d authored by svornost's avatar svornost
Browse files

Correctly store save data containing a colon in the key on windows, because...

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...
parent c8feb01c
No related branches found
No related tags found
1 merge request!12231Fixes
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment