From 4e4debb1cb65bd9f6fdd0d975e0373566b9f3423 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 25 May 2022 18:29:02 +0000 Subject: [PATCH] Remove even more of boost::filesystem --- apps/essimporter/importer.cpp | 6 +++--- apps/openmw/engine.cpp | 17 +++++++++-------- apps/openmw/mwrender/water.cpp | 6 ++---- components/crashcatcher/crashcatcher.cpp | 14 ++++++-------- components/debug/debugging.cpp | 6 ++++-- components/detournavigator/debug.cpp | 8 ++++---- components/esm4/reader.cpp | 5 ++--- components/esmloader/load.cpp | 3 ++- components/settings/parser.cpp | 13 +++++++------ 9 files changed, 39 insertions(+), 39 deletions(-) diff --git a/apps/essimporter/importer.cpp b/apps/essimporter/importer.cpp index a683bf7047..0eb377c219 100644 --- a/apps/essimporter/importer.cpp +++ b/apps/essimporter/importer.cpp @@ -1,8 +1,8 @@ #include "importer.hpp" #include - -#include +#include +#include #include #include @@ -345,7 +345,7 @@ namespace ESSImport writer.setFormat (ESM::SavedGame::sCurrentFormat); - boost::filesystem::ofstream stream(boost::filesystem::path(mOutFile), std::ios::out | std::ios::binary); + std::ofstream stream(std::filesystem::path(mOutFile), std::ios::out | std::ios::binary); // all unused writer.setVersion(0); writer.setType(0); diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 9fedd8f909..b2b1dbd0d6 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include @@ -684,7 +685,7 @@ void OMW::Engine::createWindow() void OMW::Engine::setWindowIcon() { - boost::filesystem::ifstream windowIconStream; + std::ifstream windowIconStream; std::string windowIcon = (mResDir / "mygui" / "openmw.png").string(); windowIconStream.open(windowIcon, std::ios_base::in | std::ios_base::binary); if (windowIconStream.fail()) @@ -759,13 +760,13 @@ void OMW::Engine::prepareEngine() // showing a loading screen and keeping the window responsive while doing so std::string keybinderUser = (mCfgMgr.getUserConfigPath() / "input_v3.xml").string(); - bool keybinderUserExists = boost::filesystem::exists(keybinderUser); + bool keybinderUserExists = std::filesystem::exists(keybinderUser); if(!keybinderUserExists) { std::string input2 = (mCfgMgr.getUserConfigPath() / "input_v2.xml").string(); - if(boost::filesystem::exists(input2)) { - boost::filesystem::copy_file(input2, keybinderUser); - keybinderUserExists = boost::filesystem::exists(keybinderUser); + if(std::filesystem::exists(input2)) { + std::filesystem::copy_file(input2, keybinderUser); + keybinderUserExists = std::filesystem::exists(keybinderUser); Log(Debug::Info) << "Loading keybindings file: " << keybinderUser; } } @@ -777,13 +778,13 @@ void OMW::Engine::prepareEngine() const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/gamecontrollerdb.txt"; std::string userGameControllerdb; - if (boost::filesystem::exists(userdefault)) + if (std::filesystem::exists(userdefault)) userGameControllerdb = userdefault; std::string gameControllerdb; - if (boost::filesystem::exists(localdefault)) + if (std::filesystem::exists(localdefault)) gameControllerdb = localdefault; - else if (boost::filesystem::exists(globaldefault)) + else if (std::filesystem::exists(globaldefault)) gameControllerdb = globaldefault; //else if it doesn't exist, pass in an empty string diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 9896893da2..822eab04fe 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -14,8 +14,7 @@ #include -#include -#include +#include #include #include @@ -242,8 +241,7 @@ private: osg::ref_ptr readPngImage (const std::string& file) { - // use boost in favor of osgDB::readImage, to handle utf-8 path issues on Windows - boost::filesystem::ifstream inStream; + std::ifstream inStream; inStream.open(file, std::ios_base::in | std::ios_base::binary); if (inStream.fail()) Log(Debug::Error) << "Error: Failed to open " << file; diff --git a/components/crashcatcher/crashcatcher.cpp b/components/crashcatcher/crashcatcher.cpp index c828e1ca81..efdd7c254b 100644 --- a/components/crashcatcher/crashcatcher.cpp +++ b/components/crashcatcher/crashcatcher.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -9,6 +10,8 @@ #include #include #include +#include +#include #include #include @@ -16,11 +19,6 @@ #include -#include -#include - -namespace bfs = boost::filesystem; - #include #ifdef __linux__ @@ -501,10 +499,10 @@ int crashCatcherInstallHandlers(int argc, char **argv, int num_signals, int *sig static bool is_debugger_present() { #if defined (__linux__) - bfs::path procstatus = bfs::path("/proc/self/status"); - if (bfs::exists(procstatus)) + std::filesystem::path procstatus = std::filesystem::path("/proc/self/status"); + if (std::filesystem::exists(procstatus)) { - bfs::ifstream file((procstatus)); + std::ifstream file((procstatus)); while (!file.eof()) { std::string word; diff --git a/components/debug/debugging.cpp b/components/debug/debugging.cpp index 62d1bc716d..c46971d651 100644 --- a/components/debug/debugging.cpp +++ b/components/debug/debugging.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include @@ -142,7 +144,7 @@ namespace Debug static std::unique_ptr rawStdout = nullptr; static std::unique_ptr rawStderr = nullptr; static std::unique_ptr rawStderrMutex = nullptr; -static boost::filesystem::ofstream logfile; +static std::ofstream logfile; #if defined(_WIN32) && defined(_DEBUG) static boost::iostreams::stream_buffer sb; @@ -176,7 +178,7 @@ void setupLogging(const std::string& logDir, const std::string& appName, std::io std::cerr.rdbuf(&sb); #else const std::string logName = Misc::StringUtils::lowerCase(appName) + ".log"; - logfile.open(boost::filesystem::path(logDir) / logName, mode); + logfile.open(std::filesystem::path(logDir) / logName, mode); coutsb.open(Debug::Tee(logfile, *rawStdout)); cerrsb.open(Debug::Tee(logfile, *rawStderr)); diff --git a/components/detournavigator/debug.cpp b/components/detournavigator/debug.cpp index 8394c6696d..0ddd27da5e 100644 --- a/components/detournavigator/debug.cpp +++ b/components/detournavigator/debug.cpp @@ -6,8 +6,8 @@ #include -#include -#include +#include +#include namespace DetourNavigator { @@ -15,7 +15,7 @@ namespace DetourNavigator const std::string& revision, const RecastSettings& settings) { const auto path = pathPrefix + "recastmesh" + revision + ".obj"; - boost::filesystem::ofstream file(boost::filesystem::path(path), std::ios::out); + std::ofstream file(std::filesystem::path(path), std::ios::out); if (!file.is_open()) throw NavigatorException("Open file failed: " + path); file.exceptions(std::ios::failbit | std::ios::badbit); @@ -62,7 +62,7 @@ namespace DetourNavigator }; const auto path = pathPrefix + "all_tiles_navmesh" + revision + ".bin"; - boost::filesystem::ofstream file(boost::filesystem::path(path), std::ios::out | std::ios::binary); + std::ofstream file(std::filesystem::path(path), std::ios::out | std::ios::binary); if (!file.is_open()) throw NavigatorException("Open file failed: " + path); file.exceptions(std::ios::failbit | std::ios::badbit); diff --git a/components/esm4/reader.cpp b/components/esm4/reader.cpp index 9ac8da8802..3966a18bc4 100644 --- a/components/esm4/reader.cpp +++ b/components/esm4/reader.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include // for debugging #include // for debugging #include // for debugging @@ -46,8 +47,6 @@ #include #include #include -#include -#include #include @@ -192,7 +191,7 @@ void Reader::buildLStringIndex() if ((mHeader.mFlags & Rec_ESM) == 0 || (mHeader.mFlags & Rec_Localized) == 0) return; - boost::filesystem::path p(mCtx.filename); + std::filesystem::path p(mCtx.filename); std::string filename = p.stem().filename().string(); buildLStringIndex("Strings/" + filename + "_English.STRINGS", Type_Strings); diff --git a/components/esmloader/load.cpp b/components/esmloader/load.cpp index 2705c43c49..9ab857c9f0 100644 --- a/components/esmloader/load.cpp +++ b/components/esmloader/load.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -222,7 +223,7 @@ namespace EsmLoader for (std::size_t i = 0; i < contentFiles.size(); ++i) { const std::string &file = contentFiles[i]; - const std::string extension = Misc::StringUtils::lowerCase(boost::filesystem::path(file).extension().string()); + const std::string extension = Misc::StringUtils::lowerCase(std::filesystem::path(file).extension().string()); if (supportedFormats.find(extension) == supportedFormats.end()) { diff --git a/components/settings/parser.cpp b/components/settings/parser.cpp index dd1b8c1a20..778888d2d2 100644 --- a/components/settings/parser.cpp +++ b/components/settings/parser.cpp @@ -5,7 +5,8 @@ #include #include -#include +#include +#include #include @@ -13,8 +14,8 @@ void Settings::SettingsFileParser::loadSettingsFile(const std::string& file, Cat bool base64Encoded, bool overrideExisting) { mFile = file; - boost::filesystem::ifstream fstream; - fstream.open(boost::filesystem::path(file)); + std::ifstream fstream; + fstream.open(std::filesystem::path(file)); auto stream = std::ref(fstream); std::istringstream decodedStream; @@ -106,8 +107,8 @@ void Settings::SettingsFileParser::saveSettingsFile(const std::string& file, con // Open the existing settings.cfg file to copy comments. This might not be the same file // as the output file if we're copying the setting from the default settings.cfg for the // first time. A minor change in API to pass the source file might be in order here. - boost::filesystem::ifstream istream; - boost::filesystem::path ipath(file); + std::ifstream istream; + std::filesystem::path ipath(file); istream.open(ipath); // Create a new string stream to write the current settings to. It's likely that the @@ -305,7 +306,7 @@ void Settings::SettingsFileParser::saveSettingsFile(const std::string& file, con // Now install the newly written file in the requested place. if (changed) { Log(Debug::Info) << "Updating settings file: " << ipath; - boost::filesystem::ofstream ofstream; + std::ofstream ofstream; ofstream.open(ipath); ofstream << ostream.rdbuf(); ofstream.close();