Fix crash when creating JSON file that do not exist.

Tested by: @Langbart
Refs: #6450
Differential Revision: https://code.wildfiregames.com/D4529
This was SVN commit r26604.
This commit is contained in:
Stan 2022-03-07 15:46:28 +00:00
parent 3417669e97
commit 687174e5d9

View File

@ -224,12 +224,14 @@ void WriteJSONFile(const ScriptInterface& scriptInterface, const std::wstring& f
VfsPath path(filePath);
WriteBuffer buf;
buf.Append(str.c_str(), str.length());
OsPath realPath;
g_VFS->GetRealPath(path, realPath, false);
if (g_VFS->CreateFile(path, buf.Data(), buf.Size()) == INFO::OK)
{
OsPath realPath;
g_VFS->GetRealPath(path, realPath, false);
debug_printf("FILES| JSON data written to '%s'\n", realPath.string8().c_str());
}
else
debug_printf("FILES| Failed to write JSON data to '%s'\n", realPath.string8().c_str());
debug_printf("FILES| Failed to write JSON data to '%s'\n", path.string8().c_str());
}
bool DeleteCampaignSave(const CStrW& filePath)