diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLShaderProgram.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLShaderProgram.cpp index 88001df572..f266aebb27 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLShaderProgram.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLShaderProgram.cpp @@ -74,7 +74,7 @@ std::string OpenGLShader::GetPath(const std::string& name) std::string OpenGLShader::ReadSourceCode(const std::string& path) { - auto fs = FileStream(path, FILE_MODE_OPEN); + auto fs = FileStream(path, FileMode::open); uint64_t fileLength = fs.GetLength(); if (fileLength > kMaxSourceSize) diff --git a/src/openrct2-ui/input/ShortcutManager.cpp b/src/openrct2-ui/input/ShortcutManager.cpp index 5d0e236c38..9328b3a797 100644 --- a/src/openrct2-ui/input/ShortcutManager.cpp +++ b/src/openrct2-ui/input/ShortcutManager.cpp @@ -258,7 +258,7 @@ void ShortcutManager::LoadLegacyBindings(const fs::path& path) constexpr int32_t kSupportedFileVersion = 1; constexpr int32_t kMaxLegacyShortcuts = 85; - auto fs = FileStream(path, FILE_MODE_OPEN); + auto fs = FileStream(path, FileMode::open); auto version = fs.ReadValue(); if (version == kSupportedFileVersion) { diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index 8ae1287c0c..f82076e2e7 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -334,7 +334,7 @@ namespace OpenRCT2::Ui::Windows return; auto path = _listItems[selected_list_item].path; - auto fs = FileStream(path, FILE_MODE_OPEN); + auto fs = FileStream(path, FileMode::open); ClassifiedFileInfo info; if (!TryClassifyFile(&fs, &info) || info.Type != ::FileType::park) diff --git a/src/openrct2/CommandLineSprite.cpp b/src/openrct2/CommandLineSprite.cpp index 42a97cc7b4..700cea524e 100644 --- a/src/openrct2/CommandLineSprite.cpp +++ b/src/openrct2/CommandLineSprite.cpp @@ -115,7 +115,7 @@ std::optional SpriteFile::Open(const utf8* path) { try { - OpenRCT2::FileStream stream(path, OpenRCT2::FILE_MODE_OPEN); + OpenRCT2::FileStream stream(path, OpenRCT2::FileMode::open); SpriteFile spriteFile; stream.Read(&spriteFile.Header, sizeof(RCTG1Header)); @@ -155,7 +155,7 @@ bool SpriteFile::Save(const utf8* path) { try { - OpenRCT2::FileStream stream(path, OpenRCT2::FILE_MODE_WRITE); + OpenRCT2::FileStream stream(path, OpenRCT2::FileMode::write); stream.Write(&Header, sizeof(RCTG1Header)); if (Header.num_entries > 0) @@ -628,8 +628,8 @@ static int32_t CommandLineForSpriteCombine(const char** argv, int32_t argc) const utf8* dataFile = argv[2]; const utf8* outputPath = argv[3]; - auto fileHeader = OpenRCT2::FileStream(indexFile, OpenRCT2::FILE_MODE_OPEN); - auto fileData = OpenRCT2::FileStream(dataFile, OpenRCT2::FILE_MODE_OPEN); + auto fileHeader = OpenRCT2::FileStream(indexFile, OpenRCT2::FileMode::open); + auto fileData = OpenRCT2::FileStream(dataFile, OpenRCT2::FileMode::open); auto fileHeaderSize = fileHeader.GetLength(); auto fileDataSize = fileData.GetLength(); @@ -638,7 +638,7 @@ static int32_t CommandLineForSpriteCombine(const char** argv, int32_t argc) RCTG1Header header = {}; header.num_entries = numEntries; header.total_size = fileDataSize; - OpenRCT2::FileStream outputStream(outputPath, OpenRCT2::FILE_MODE_WRITE); + OpenRCT2::FileStream outputStream(outputPath, OpenRCT2::FileMode::write); outputStream.Write(&header, sizeof(RCTG1Header)); auto g1Elements32 = std::make_unique(numEntries); diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 9b059a4bb1..10201a152b 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -738,7 +738,7 @@ namespace OpenRCT2 return true; } - auto fs = FileStream(path, FILE_MODE_OPEN); + auto fs = FileStream(path, FileMode::open); if (!LoadParkFromStream(&fs, path, loadTitleScreenOnFail, asScenario)) { return false; diff --git a/src/openrct2/FileClassifier.cpp b/src/openrct2/FileClassifier.cpp index 56a0484418..2195bc0d2e 100644 --- a/src/openrct2/FileClassifier.cpp +++ b/src/openrct2/FileClassifier.cpp @@ -32,7 +32,7 @@ bool TryClassifyFile(const std::string& path, ClassifiedFileInfo* result) { try { - auto fs = OpenRCT2::FileStream(path, OpenRCT2::FILE_MODE_OPEN); + auto fs = OpenRCT2::FileStream(path, OpenRCT2::FileMode::open); return TryClassifyFile(&fs, result); } catch (const std::exception&) diff --git a/src/openrct2/command_line/ParkInfoCommands.cpp b/src/openrct2/command_line/ParkInfoCommands.cpp index ff212d5d5f..2c74873f76 100644 --- a/src/openrct2/command_line/ParkInfoCommands.cpp +++ b/src/openrct2/command_line/ParkInfoCommands.cpp @@ -55,7 +55,7 @@ static exitcode_t HandleObjectsInfo(CommandLineArgEnumerator* argEnumerator) auto context = OpenRCT2::CreateContext(); context->Initialise(); - auto stream = OpenRCT2::FileStream(sourcePath, OpenRCT2::FILE_MODE_OPEN); + auto stream = OpenRCT2::FileStream(sourcePath, OpenRCT2::FileMode::open); ClassifiedFileInfo info; if (!TryClassifyFile(&stream, &info)) { diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 342a73ce85..d2d0622205 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -647,7 +647,7 @@ namespace OpenRCT2::Config { try { - auto fs = FileStream(path, FILE_MODE_OPEN); + auto fs = FileStream(path, FileMode::open); auto reader = CreateIniReader(&fs); ReadGeneral(reader.get()); ReadInterface(reader.get()); @@ -671,7 +671,7 @@ namespace OpenRCT2::Config auto directory = Path::GetDirectory(path); Path::CreateDirectory(directory); - auto fs = FileStream(path, FILE_MODE_WRITE); + auto fs = FileStream(path, FileMode::write); auto writer = CreateIniWriter(&fs); WriteGeneral(writer.get()); WriteInterface(writer.get()); diff --git a/src/openrct2/core/File.cpp b/src/openrct2/core/File.cpp index c5fcc0b02e..1296e1cba0 100644 --- a/src/openrct2/core/File.cpp +++ b/src/openrct2/core/File.cpp @@ -124,7 +124,7 @@ namespace OpenRCT2::File void WriteAllBytes(u8string_view path, const void* buffer, size_t length) { - auto fs = OpenRCT2::FileStream(path, OpenRCT2::FILE_MODE_WRITE); + auto fs = OpenRCT2::FileStream(path, OpenRCT2::FileMode::write); fs.Write(buffer, length); } diff --git a/src/openrct2/core/FileIndex.hpp b/src/openrct2/core/FileIndex.hpp index 8113f4ec0b..ac22a656a5 100644 --- a/src/openrct2/core/FileIndex.hpp +++ b/src/openrct2/core/FileIndex.hpp @@ -219,7 +219,7 @@ private: try { LOG_VERBOSE("FileIndex:Loading index: '%s'", _indexPath.c_str()); - auto fs = OpenRCT2::FileStream(_indexPath, OpenRCT2::FILE_MODE_OPEN); + auto fs = OpenRCT2::FileStream(_indexPath, OpenRCT2::FileMode::open); // Read header, check if we need to re-scan auto header = fs.ReadValue(); @@ -260,7 +260,7 @@ private: { LOG_VERBOSE("FileIndex:Writing index: '%s'", _indexPath.c_str()); OpenRCT2::Path::CreateDirectory(OpenRCT2::Path::GetDirectory(_indexPath)); - auto fs = OpenRCT2::FileStream(_indexPath, OpenRCT2::FILE_MODE_WRITE); + auto fs = OpenRCT2::FileStream(_indexPath, OpenRCT2::FileMode::write); // Write header FileIndexHeader header; diff --git a/src/openrct2/core/FileStream.cpp b/src/openrct2/core/FileStream.cpp index 2be57e3ef7..2a432cb5d9 100644 --- a/src/openrct2/core/FileStream.cpp +++ b/src/openrct2/core/FileStream.cpp @@ -27,37 +27,37 @@ namespace OpenRCT2 { - FileStream::FileStream(const fs::path& path, int32_t fileMode) + FileStream::FileStream(const fs::path& path, FileMode fileMode) : FileStream(path.u8string(), fileMode) { } - FileStream::FileStream(const std::string& path, int32_t fileMode) + FileStream::FileStream(const std::string& path, FileMode fileMode) : FileStream(path.c_str(), fileMode) { } - FileStream::FileStream(std::string_view path, int32_t fileMode) + FileStream::FileStream(std::string_view path, FileMode fileMode) : FileStream(std::string(path), fileMode) { } - FileStream::FileStream(const utf8* path, int32_t fileMode) + FileStream::FileStream(const utf8* path, FileMode fileMode) { const char* mode; switch (fileMode) { - case FILE_MODE_OPEN: + case FileMode::open: mode = "rb"; _canRead = true; _canWrite = false; break; - case FILE_MODE_WRITE: + case FileMode::write: mode = "w+b"; _canRead = true; _canWrite = true; break; - case FILE_MODE_APPEND: + case FileMode::append: mode = "a"; _canRead = false; _canWrite = true; @@ -81,7 +81,7 @@ namespace OpenRCT2 auto modeW = String::toWideChar(mode); _file = _wfopen(pathW.c_str(), modeW.c_str()); #else - if (fileMode == FILE_MODE_OPEN) + if (fileMode == FileMode::open) { struct stat fileStat; // Only allow regular files to be opened as its possible to open directories. diff --git a/src/openrct2/core/FileStream.h b/src/openrct2/core/FileStream.h index 7430566636..2eff04acdd 100644 --- a/src/openrct2/core/FileStream.h +++ b/src/openrct2/core/FileStream.h @@ -14,11 +14,11 @@ namespace OpenRCT2 { - enum + enum class FileMode : uint8_t { - FILE_MODE_OPEN, - FILE_MODE_WRITE, - FILE_MODE_APPEND, + open, + write, + append, }; /** @@ -35,10 +35,10 @@ namespace OpenRCT2 uint64_t _fileSize = 0; public: - FileStream(const fs::path& path, int32_t fileMode); - FileStream(const std::string& path, int32_t fileMode); - FileStream(std::string_view path, int32_t fileMode); - FileStream(const utf8* path, int32_t fileMode); + FileStream(const fs::path& path, FileMode fileMode); + FileStream(const std::string& path, FileMode fileMode); + FileStream(std::string_view path, FileMode fileMode); + FileStream(const utf8* path, FileMode fileMode); ~FileStream() override; bool CanRead() const override; diff --git a/src/openrct2/core/Json.cpp b/src/openrct2/core/Json.cpp index b346123249..4912797bfb 100644 --- a/src/openrct2/core/Json.cpp +++ b/src/openrct2/core/Json.cpp @@ -18,7 +18,7 @@ namespace OpenRCT2::Json { json_t ReadFromFile(u8string_view path, size_t maxSize) { - auto fs = OpenRCT2::FileStream(path, OpenRCT2::FILE_MODE_OPEN); + auto fs = OpenRCT2::FileStream(path, OpenRCT2::FileMode::open); size_t fileLength = static_cast(fs.GetLength()); if (fileLength > maxSize) @@ -50,7 +50,7 @@ namespace OpenRCT2::Json std::string jsonOutput = jsonData.dump(indentSize); // Write to file - auto fs = OpenRCT2::FileStream(path, OpenRCT2::FILE_MODE_WRITE); + auto fs = OpenRCT2::FileStream(path, OpenRCT2::FileMode::write); fs.Write(jsonOutput.data(), jsonOutput.size()); } diff --git a/src/openrct2/drawing/Drawing.Sprite.cpp b/src/openrct2/drawing/Drawing.Sprite.cpp index 7dd40f7612..2cb167530d 100644 --- a/src/openrct2/drawing/Drawing.Sprite.cpp +++ b/src/openrct2/drawing/Drawing.Sprite.cpp @@ -452,7 +452,7 @@ bool GfxLoadG1(const IPlatformEnvironment& env) try { auto path = env.FindFile(DIRBASE::RCT2, DIRID::DATA, u8"g1.dat"); - auto fs = FileStream(path, FILE_MODE_OPEN); + auto fs = FileStream(path, FileMode::open); _g1.header = fs.ReadValue(); LOG_VERBOSE("g1.dat, number of entries: %u", _g1.header.num_entries); @@ -532,7 +532,7 @@ bool GfxLoadG2() try { - auto fs = FileStream(path, FILE_MODE_OPEN); + auto fs = FileStream(path, FileMode::open); _g2.header = fs.ReadValue(); // Read element headers @@ -601,8 +601,8 @@ bool GfxLoadCsg() auto pathDataPath = FindCsg1datAtLocation(Config::Get().general.RCT1Path); try { - auto fileHeader = FileStream(pathHeaderPath, FILE_MODE_OPEN); - auto fileData = FileStream(pathDataPath, FILE_MODE_OPEN); + auto fileHeader = FileStream(pathHeaderPath, FileMode::open); + auto fileData = FileStream(pathDataPath, FileMode::open); size_t fileHeaderSize = fileHeader.GetLength(); size_t fileDataSize = fileData.GetLength(); diff --git a/src/openrct2/localisation/LanguagePack.cpp b/src/openrct2/localisation/LanguagePack.cpp index fe6d86498e..c6eb9fc5bd 100644 --- a/src/openrct2/localisation/LanguagePack.cpp +++ b/src/openrct2/localisation/LanguagePack.cpp @@ -45,7 +45,7 @@ public: try { - OpenRCT2::FileStream fs = OpenRCT2::FileStream(path, OpenRCT2::FILE_MODE_OPEN); + OpenRCT2::FileStream fs = OpenRCT2::FileStream(path, OpenRCT2::FileMode::open); size_t fileLength = static_cast(fs.GetLength()); if (fileLength > MAX_LANGUAGE_SIZE) diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 3b3bcf65bf..9526910710 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -302,7 +302,7 @@ bool NetworkBase::BeginClient(const std::string& host, uint16_t port) try { - auto fs = FileStream(keyPath, FILE_MODE_WRITE); + auto fs = FileStream(keyPath, FileMode::write); _key.SavePrivate(&fs); } catch (const std::exception&) @@ -318,7 +318,7 @@ bool NetworkBase::BeginClient(const std::string& host, uint16_t port) try { - auto fs = FileStream(keyPath, FILE_MODE_WRITE); + auto fs = FileStream(keyPath, FileMode::write); _key.SavePublic(&fs); } catch (const std::exception&) @@ -334,7 +334,7 @@ bool NetworkBase::BeginClient(const std::string& host, uint16_t port) try { LOG_VERBOSE("Loading key from %s", keyPath.c_str()); - auto fs = FileStream(keyPath, FILE_MODE_OPEN); + auto fs = FileStream(keyPath, FileMode::open); ok = _key.LoadPrivate(&fs); } catch (const std::exception&) @@ -2212,7 +2212,7 @@ void NetworkBase::Client_Handle_TOKEN(NetworkConnection& connection, NetworkPack try { - auto fs = FileStream(keyPath, FILE_MODE_OPEN); + auto fs = FileStream(keyPath, FileMode::open); if (!_key.LoadPrivate(&fs)) { throw std::runtime_error("Failed to load private key."); @@ -3972,7 +3972,7 @@ void NetworkSendPassword(const std::string& password) } try { - auto fs = FileStream(keyPath, FILE_MODE_OPEN); + auto fs = FileStream(keyPath, FileMode::open); network._key.LoadPrivate(&fs); } catch (const std::exception&) diff --git a/src/openrct2/network/ServerList.cpp b/src/openrct2/network/ServerList.cpp index d31d6b41f8..0b392edd3e 100644 --- a/src/openrct2/network/ServerList.cpp +++ b/src/openrct2/network/ServerList.cpp @@ -193,7 +193,7 @@ std::vector ServerList::ReadFavourites() const auto path = env->GetFilePath(PATHID::NETWORK_SERVERS); if (File::Exists(path)) { - auto fs = FileStream(path, FILE_MODE_OPEN); + auto fs = FileStream(path, FileMode::open); auto numEntries = fs.ReadValue(); for (size_t i = 0; i < numEntries; i++) { @@ -247,7 +247,7 @@ bool ServerList::WriteFavourites(const std::vector& entries) co try { - auto fs = FileStream(path, FILE_MODE_WRITE); + auto fs = FileStream(path, FileMode::write); fs.WriteValue(static_cast(entries.size())); for (const auto& entry : entries) { diff --git a/src/openrct2/object/Object.cpp b/src/openrct2/object/Object.cpp index e33ddd1011..79f1a13f01 100644 --- a/src/openrct2/object/Object.cpp +++ b/src/openrct2/object/Object.cpp @@ -356,7 +356,7 @@ std::unique_ptr ObjectAsset::GetStream() const { if (_zipPath.empty()) { - return std::make_unique(_path, FILE_MODE_OPEN); + return std::make_unique(_path, FileMode::open); } auto zipArchive = Zip::TryOpen(_zipPath, ZIP_ACCESS::READ); diff --git a/src/openrct2/object/ObjectFactory.cpp b/src/openrct2/object/ObjectFactory.cpp index 46f9b10e2b..bf610bfd2c 100644 --- a/src/openrct2/object/ObjectFactory.cpp +++ b/src/openrct2/object/ObjectFactory.cpp @@ -267,7 +267,7 @@ namespace OpenRCT2::ObjectFactory std::unique_ptr result; try { - auto fs = OpenRCT2::FileStream(path, OpenRCT2::FILE_MODE_OPEN); + auto fs = OpenRCT2::FileStream(path, OpenRCT2::FileMode::open); auto chunkReader = SawyerChunkReader(&fs); RCTObjectEntry entry = fs.ReadValue(); diff --git a/src/openrct2/object/ObjectRepository.cpp b/src/openrct2/object/ObjectRepository.cpp index 5f74f507e4..5930e0d4d4 100644 --- a/src/openrct2/object/ObjectRepository.cpp +++ b/src/openrct2/object/ObjectRepository.cpp @@ -540,7 +540,7 @@ private: // Save to file try { - auto fs = FileStream(std::string(path), FILE_MODE_WRITE); + auto fs = FileStream(std::string(path), FileMode::write); fs.Write(entry, sizeof(RCTObjectEntry)); fs.Write(encodedDataBuffer, encodedDataSize); @@ -641,7 +641,7 @@ private: } // Read object data from file - auto fs = OpenRCT2::FileStream(item->Path, OpenRCT2::FILE_MODE_OPEN); + auto fs = OpenRCT2::FileStream(item->Path, OpenRCT2::FileMode::open); auto fileEntry = fs.ReadValue(); if (*entry != fileEntry) { diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index ccebc83cff..cce8ec806f 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -133,7 +133,7 @@ namespace OpenRCT2 void Load(const std::string_view path) { - FileStream fs(path, FILE_MODE_OPEN); + FileStream fs(path, FileMode::open); Load(fs); } @@ -204,7 +204,7 @@ namespace OpenRCT2 void Save(GameState_t& gameState, const std::string_view path) { - FileStream fs(path, FILE_MODE_WRITE); + FileStream fs(path, FileMode::write); Save(gameState, fs); } diff --git a/src/openrct2/rct1/Csg.cpp b/src/openrct2/rct1/Csg.cpp index f115ac71b1..b82d735a47 100644 --- a/src/openrct2/rct1/Csg.cpp +++ b/src/openrct2/rct1/Csg.cpp @@ -80,8 +80,8 @@ bool CsgAtLocationIsUsable(u8string_view path) return false; } - auto fileHeader = FileStream(csg1HeaderPath, FILE_MODE_OPEN); - auto fileData = FileStream(csg1DataPath, FILE_MODE_OPEN); + auto fileHeader = FileStream(csg1HeaderPath, FileMode::open); + auto fileData = FileStream(csg1DataPath, FileMode::open); size_t fileHeaderSize = fileHeader.GetLength(); size_t fileDataSize = fileData.GetLength(); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 57af905177..194951cf4d 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -162,14 +162,14 @@ namespace OpenRCT2::RCT1 ParkLoadResult LoadSavedGame(const u8string& path, bool skipObjectCheck = false) override { - auto fs = FileStream(path, FILE_MODE_OPEN); + auto fs = FileStream(path, FileMode::open); auto result = LoadFromStream(&fs, false, skipObjectCheck, path); return result; } ParkLoadResult LoadScenario(const u8string& path, bool skipObjectCheck = false) override { - auto fs = FileStream(path, FILE_MODE_OPEN); + auto fs = FileStream(path, FileMode::open); auto result = LoadFromStream(&fs, true, skipObjectCheck, path); return result; } diff --git a/src/openrct2/rct1/T4Importer.cpp b/src/openrct2/rct1/T4Importer.cpp index 5ac93fc716..dc2bfdcb17 100644 --- a/src/openrct2/rct1/T4Importer.cpp +++ b/src/openrct2/rct1/T4Importer.cpp @@ -47,7 +47,7 @@ namespace OpenRCT2::RCT1 if (String::iequals(extension, ".td4")) { _name = GetNameFromTrackPath(path); - auto fs = OpenRCT2::FileStream(path, OpenRCT2::FILE_MODE_OPEN); + auto fs = OpenRCT2::FileStream(path, OpenRCT2::FileMode::open); return LoadFromStream(&fs); } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index b7e95846c1..95d1e9ccc1 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -140,7 +140,7 @@ namespace OpenRCT2::RCT2 ParkLoadResult LoadSavedGame(const u8string& path, bool skipObjectCheck = false) override { - auto fs = OpenRCT2::FileStream(path, OpenRCT2::FILE_MODE_OPEN); + auto fs = OpenRCT2::FileStream(path, OpenRCT2::FileMode::open); auto result = LoadFromStream(&fs, false, skipObjectCheck); _s6Path = path; return result; @@ -148,7 +148,7 @@ namespace OpenRCT2::RCT2 ParkLoadResult LoadScenario(const u8string& path, bool skipObjectCheck = false) override { - auto fs = OpenRCT2::FileStream(path, OpenRCT2::FILE_MODE_OPEN); + auto fs = OpenRCT2::FileStream(path, OpenRCT2::FileMode::open); auto result = LoadFromStream(&fs, true, skipObjectCheck); _s6Path = path; return result; diff --git a/src/openrct2/rct2/T6Exporter.cpp b/src/openrct2/rct2/T6Exporter.cpp index ef79af3c94..827f30b340 100644 --- a/src/openrct2/rct2/T6Exporter.cpp +++ b/src/openrct2/rct2/T6Exporter.cpp @@ -39,7 +39,7 @@ namespace OpenRCT2::RCT2 { try { - auto fs = OpenRCT2::FileStream(path, OpenRCT2::FILE_MODE_WRITE); + auto fs = OpenRCT2::FileStream(path, OpenRCT2::FileMode::write); return SaveTrack(&fs); } catch (const std::exception& e) diff --git a/src/openrct2/rct2/T6Importer.cpp b/src/openrct2/rct2/T6Importer.cpp index 71cdf547c5..8c63ea3a87 100644 --- a/src/openrct2/rct2/T6Importer.cpp +++ b/src/openrct2/rct2/T6Importer.cpp @@ -50,7 +50,7 @@ namespace OpenRCT2::RCT2 if (String::iequals(extension, ".td6")) { _name = GetNameFromTrackPath(path); - auto fs = OpenRCT2::FileStream(path, OpenRCT2::FILE_MODE_OPEN); + auto fs = OpenRCT2::FileStream(path, OpenRCT2::FileMode::open); return LoadFromStream(&fs); } diff --git a/src/openrct2/scenario/ScenarioRepository.cpp b/src/openrct2/scenario/ScenarioRepository.cpp index aafb15a9c3..a59b413e78 100644 --- a/src/openrct2/scenario/ScenarioRepository.cpp +++ b/src/openrct2/scenario/ScenarioRepository.cpp @@ -192,7 +192,7 @@ private: return ms; } - auto fs = std::make_unique(path, FILE_MODE_OPEN); + auto fs = std::make_unique(path, FileMode::open); return fs; } @@ -534,7 +534,7 @@ private: try { - auto fs = FileStream(path, FILE_MODE_OPEN); + auto fs = FileStream(path, FileMode::open); uint32_t fileVersion = fs.ReadValue(); if (fileVersion != 1 && fileVersion != 2) { @@ -582,7 +582,7 @@ private: bool highscoresDirty = false; try { - auto fs = FileStream(path, FILE_MODE_OPEN); + auto fs = FileStream(path, FileMode::open); if (fs.GetLength() <= 4) { // Initial value of scores for RCT2, just ignore @@ -673,7 +673,7 @@ private: std::string path = _env->GetFilePath(PATHID::SCORES); try { - auto fs = FileStream(path, FILE_MODE_WRITE); + auto fs = FileStream(path, FileMode::write); fs.WriteValue(HighscoreFileVersion); fs.WriteValue(static_cast(_highscores.size())); for (size_t i = 0; i < _highscores.size(); i++) diff --git a/src/openrct2/scenes/title/TitleSequence.cpp b/src/openrct2/scenes/title/TitleSequence.cpp index b72c0f1ad0..774e24ebbb 100644 --- a/src/openrct2/scenes/title/TitleSequence.cpp +++ b/src/openrct2/scenes/title/TitleSequence.cpp @@ -133,7 +133,7 @@ namespace OpenRCT2::Title std::unique_ptr fileStream = nullptr; try { - fileStream = std::make_unique(absolutePath, OpenRCT2::FILE_MODE_OPEN); + fileStream = std::make_unique(absolutePath, OpenRCT2::FileMode::open); } catch (const IOException& exception) { @@ -484,7 +484,7 @@ namespace OpenRCT2::Title std::vector result; try { - auto fs = OpenRCT2::FileStream(path, OpenRCT2::FILE_MODE_OPEN); + auto fs = OpenRCT2::FileStream(path, OpenRCT2::FileMode::open); auto size = static_cast(fs.GetLength()); result.resize(size); fs.Read(result.data(), size);