1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-03 21:09:41 +00:00

Merge branch 'moar_noboost' into 'master'

Remove even more of boost::filesystem

See merge request OpenMW/openmw!1927
This commit is contained in:
Petr Mikheev 2022-05-25 18:29:04 +00:00
commit 29328867dc
9 changed files with 39 additions and 39 deletions

View file

@ -1,8 +1,8 @@
#include "importer.hpp" #include "importer.hpp"
#include <iomanip> #include <iomanip>
#include <filesystem>
#include <boost/filesystem/fstream.hpp> #include <fstream>
#include <osgDB/ReadFile> #include <osgDB/ReadFile>
#include <osg/ImageUtils> #include <osg/ImageUtils>
@ -345,7 +345,7 @@ namespace ESSImport
writer.setFormat (ESM::SavedGame::sCurrentFormat); 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 // all unused
writer.setVersion(0); writer.setVersion(0);
writer.setType(0); writer.setType(0);

View file

@ -3,6 +3,7 @@
#include <iomanip> #include <iomanip>
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include <filesystem>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
@ -684,7 +685,7 @@ void OMW::Engine::createWindow()
void OMW::Engine::setWindowIcon() void OMW::Engine::setWindowIcon()
{ {
boost::filesystem::ifstream windowIconStream; std::ifstream windowIconStream;
std::string windowIcon = (mResDir / "mygui" / "openmw.png").string(); std::string windowIcon = (mResDir / "mygui" / "openmw.png").string();
windowIconStream.open(windowIcon, std::ios_base::in | std::ios_base::binary); windowIconStream.open(windowIcon, std::ios_base::in | std::ios_base::binary);
if (windowIconStream.fail()) if (windowIconStream.fail())
@ -759,13 +760,13 @@ void OMW::Engine::prepareEngine()
// showing a loading screen and keeping the window responsive while doing so // showing a loading screen and keeping the window responsive while doing so
std::string keybinderUser = (mCfgMgr.getUserConfigPath() / "input_v3.xml").string(); std::string keybinderUser = (mCfgMgr.getUserConfigPath() / "input_v3.xml").string();
bool keybinderUserExists = boost::filesystem::exists(keybinderUser); bool keybinderUserExists = std::filesystem::exists(keybinderUser);
if(!keybinderUserExists) if(!keybinderUserExists)
{ {
std::string input2 = (mCfgMgr.getUserConfigPath() / "input_v2.xml").string(); std::string input2 = (mCfgMgr.getUserConfigPath() / "input_v2.xml").string();
if(boost::filesystem::exists(input2)) { if(std::filesystem::exists(input2)) {
boost::filesystem::copy_file(input2, keybinderUser); std::filesystem::copy_file(input2, keybinderUser);
keybinderUserExists = boost::filesystem::exists(keybinderUser); keybinderUserExists = std::filesystem::exists(keybinderUser);
Log(Debug::Info) << "Loading keybindings file: " << 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"; const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/gamecontrollerdb.txt";
std::string userGameControllerdb; std::string userGameControllerdb;
if (boost::filesystem::exists(userdefault)) if (std::filesystem::exists(userdefault))
userGameControllerdb = userdefault; userGameControllerdb = userdefault;
std::string gameControllerdb; std::string gameControllerdb;
if (boost::filesystem::exists(localdefault)) if (std::filesystem::exists(localdefault))
gameControllerdb = localdefault; gameControllerdb = localdefault;
else if (boost::filesystem::exists(globaldefault)) else if (std::filesystem::exists(globaldefault))
gameControllerdb = globaldefault; gameControllerdb = globaldefault;
//else if it doesn't exist, pass in an empty string //else if it doesn't exist, pass in an empty string

View file

@ -14,8 +14,7 @@
#include <osgDB/ReadFile> #include <osgDB/ReadFile>
#include <boost/filesystem/path.hpp> #include <fstream>
#include <boost/filesystem/fstream.hpp>
#include <osgUtil/IncrementalCompileOperation> #include <osgUtil/IncrementalCompileOperation>
#include <osgUtil/CullVisitor> #include <osgUtil/CullVisitor>
@ -242,8 +241,7 @@ private:
osg::ref_ptr<osg::Image> readPngImage (const std::string& file) osg::ref_ptr<osg::Image> readPngImage (const std::string& file)
{ {
// use boost in favor of osgDB::readImage, to handle utf-8 path issues on Windows std::ifstream inStream;
boost::filesystem::ifstream inStream;
inStream.open(file, std::ios_base::in | std::ios_base::binary); inStream.open(file, std::ios_base::in | std::ios_base::binary);
if (inStream.fail()) if (inStream.fail())
Log(Debug::Error) << "Error: Failed to open " << file; Log(Debug::Error) << "Error: Failed to open " << file;

View file

@ -1,4 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include <cstring>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
@ -9,6 +10,8 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
#include <fstream>
#include <filesystem>
#include <pthread.h> #include <pthread.h>
#include <stdbool.h> #include <stdbool.h>
@ -16,11 +19,6 @@
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/operations.hpp>
namespace bfs = boost::filesystem;
#include <SDL_messagebox.h> #include <SDL_messagebox.h>
#ifdef __linux__ #ifdef __linux__
@ -501,10 +499,10 @@ int crashCatcherInstallHandlers(int argc, char **argv, int num_signals, int *sig
static bool is_debugger_present() static bool is_debugger_present()
{ {
#if defined (__linux__) #if defined (__linux__)
bfs::path procstatus = bfs::path("/proc/self/status"); std::filesystem::path procstatus = std::filesystem::path("/proc/self/status");
if (bfs::exists(procstatus)) if (std::filesystem::exists(procstatus))
{ {
bfs::ifstream file((procstatus)); std::ifstream file((procstatus));
while (!file.eof()) while (!file.eof())
{ {
std::string word; std::string word;

View file

@ -3,6 +3,8 @@
#include <chrono> #include <chrono>
#include <memory> #include <memory>
#include <functional> #include <functional>
#include <fstream>
#include <filesystem>
#include <components/crashcatcher/crashcatcher.hpp> #include <components/crashcatcher/crashcatcher.hpp>
@ -142,7 +144,7 @@ namespace Debug
static std::unique_ptr<std::ostream> rawStdout = nullptr; static std::unique_ptr<std::ostream> rawStdout = nullptr;
static std::unique_ptr<std::ostream> rawStderr = nullptr; static std::unique_ptr<std::ostream> rawStderr = nullptr;
static std::unique_ptr<std::mutex> rawStderrMutex = nullptr; static std::unique_ptr<std::mutex> rawStderrMutex = nullptr;
static boost::filesystem::ofstream logfile; static std::ofstream logfile;
#if defined(_WIN32) && defined(_DEBUG) #if defined(_WIN32) && defined(_DEBUG)
static boost::iostreams::stream_buffer<Debug::DebugOutput> sb; static boost::iostreams::stream_buffer<Debug::DebugOutput> sb;
@ -176,7 +178,7 @@ void setupLogging(const std::string& logDir, const std::string& appName, std::io
std::cerr.rdbuf(&sb); std::cerr.rdbuf(&sb);
#else #else
const std::string logName = Misc::StringUtils::lowerCase(appName) + ".log"; 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)); coutsb.open(Debug::Tee(logfile, *rawStdout));
cerrsb.open(Debug::Tee(logfile, *rawStderr)); cerrsb.open(Debug::Tee(logfile, *rawStderr));

View file

@ -6,8 +6,8 @@
#include <DetourNavMesh.h> #include <DetourNavMesh.h>
#include <boost/filesystem.hpp> #include <filesystem>
#include <boost/filesystem/fstream.hpp> #include <fstream>
namespace DetourNavigator namespace DetourNavigator
{ {
@ -15,7 +15,7 @@ namespace DetourNavigator
const std::string& revision, const RecastSettings& settings) const std::string& revision, const RecastSettings& settings)
{ {
const auto path = pathPrefix + "recastmesh" + revision + ".obj"; 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()) if (!file.is_open())
throw NavigatorException("Open file failed: " + path); throw NavigatorException("Open file failed: " + path);
file.exceptions(std::ios::failbit | std::ios::badbit); file.exceptions(std::ios::failbit | std::ios::badbit);
@ -62,7 +62,7 @@ namespace DetourNavigator
}; };
const auto path = pathPrefix + "all_tiles_navmesh" + revision + ".bin"; 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()) if (!file.is_open())
throw NavigatorException("Open file failed: " + path); throw NavigatorException("Open file failed: " + path);
file.exceptions(std::ios::failbit | std::ios::badbit); file.exceptions(std::ios::failbit | std::ios::badbit);

View file

@ -31,6 +31,7 @@
#include <cassert> #include <cassert>
#include <stdexcept> #include <stdexcept>
#include <unordered_map> #include <unordered_map>
#include <filesystem>
#include <iostream> // for debugging #include <iostream> // for debugging
#include <sstream> // for debugging #include <sstream> // for debugging
#include <iomanip> // for debugging #include <iomanip> // for debugging
@ -46,8 +47,6 @@
#include <boost/iostreams/filtering_streambuf.hpp> #include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp> #include <boost/iostreams/copy.hpp>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <components/bsa/memorystream.hpp> #include <components/bsa/memorystream.hpp>
@ -192,7 +191,7 @@ void Reader::buildLStringIndex()
if ((mHeader.mFlags & Rec_ESM) == 0 || (mHeader.mFlags & Rec_Localized) == 0) if ((mHeader.mFlags & Rec_ESM) == 0 || (mHeader.mFlags & Rec_Localized) == 0)
return; return;
boost::filesystem::path p(mCtx.filename); std::filesystem::path p(mCtx.filename);
std::string filename = p.stem().filename().string(); std::string filename = p.stem().filename().string();
buildLStringIndex("Strings/" + filename + "_English.STRINGS", Type_Strings); buildLStringIndex("Strings/" + filename + "_English.STRINGS", Type_Strings);

View file

@ -20,6 +20,7 @@
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>
#include <algorithm> #include <algorithm>
#include <filesystem>
#include <cstddef> #include <cstddef>
#include <map> #include <map>
#include <set> #include <set>
@ -222,7 +223,7 @@ namespace EsmLoader
for (std::size_t i = 0; i < contentFiles.size(); ++i) for (std::size_t i = 0; i < contentFiles.size(); ++i)
{ {
const std::string &file = contentFiles[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()) if (supportedFormats.find(extension) == supportedFormats.end())
{ {

View file

@ -5,7 +5,8 @@
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>
#include <boost/filesystem/fstream.hpp> #include <fstream>
#include <filesystem>
#include <Base64.h> #include <Base64.h>
@ -13,8 +14,8 @@ void Settings::SettingsFileParser::loadSettingsFile(const std::string& file, Cat
bool base64Encoded, bool overrideExisting) bool base64Encoded, bool overrideExisting)
{ {
mFile = file; mFile = file;
boost::filesystem::ifstream fstream; std::ifstream fstream;
fstream.open(boost::filesystem::path(file)); fstream.open(std::filesystem::path(file));
auto stream = std::ref<std::istream>(fstream); auto stream = std::ref<std::istream>(fstream);
std::istringstream decodedStream; 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 // 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 // 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. // first time. A minor change in API to pass the source file might be in order here.
boost::filesystem::ifstream istream; std::ifstream istream;
boost::filesystem::path ipath(file); std::filesystem::path ipath(file);
istream.open(ipath); istream.open(ipath);
// Create a new string stream to write the current settings to. It's likely that the // 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. // Now install the newly written file in the requested place.
if (changed) { if (changed) {
Log(Debug::Info) << "Updating settings file: " << ipath; Log(Debug::Info) << "Updating settings file: " << ipath;
boost::filesystem::ofstream ofstream; std::ofstream ofstream;
ofstream.open(ipath); ofstream.open(ipath);
ofstream << ostream.rdbuf(); ofstream << ostream.rdbuf();
ofstream.close(); ofstream.close();