| 6 | namespace OpenLoco |
| 7 | { |
| 8 | static FILE* fileOpen(const std::filesystem::path& path, StreamMode mode) |
| 9 | { |
| 10 | if (mode == StreamMode::none) |
| 11 | { |
| 12 | throw Exception::InvalidArgument("Invalid mode argument"); |
| 13 | } |
| 14 | #ifdef _WIN32 |
| 15 | FILE* fs; |
| 16 | _wfopen_s(&fs, path.wstring().c_str(), mode == StreamMode::read ? L"rb" : L"wb"); |
| 17 | return fs; |
| 18 | #else |
| 19 | return fopen(path.u8string().c_str(), mode == StreamMode::read ? "rb" : "wb"); |
| 20 | #endif |
| 21 | } |
| 22 | |
| 23 | static size_t fileTell(FILE* fs) |
| 24 | { |