1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Ensure path exists for writable filestreams

This commit is contained in:
Hielke Morsink
2018-02-08 01:49:45 +01:00
parent c81bf7b501
commit b54574fe19

View File

@@ -12,6 +12,7 @@
#include "../common.h"
#include "../localisation/Language.h"
#include "IStream.hpp"
#include "Path.hpp"
#include "String.hpp"
#include <algorithm>
@@ -81,6 +82,16 @@ namespace OpenRCT2
throw;
}
// Make sure the directory exists before writing to a file inside it
if (_canWrite)
{
std::string directory = Path::GetDirectory(path);
if (!Path::DirectoryExists(directory))
{
Path::CreateDirectory(directory);
}
}
#ifdef _WIN32
auto pathW = String::ToWideChar(path);
auto modeW = String::ToWideChar(mode);