Replace all remaining occurrences of boost::filesystem with std::filesystem.

crashfix_debugdraw
Project579 3 years ago
parent 25fa8c3656
commit 4bb07282c9

@ -15,7 +15,6 @@ openmw_add_executable(openmw-iniimporter
target_link_libraries(openmw-iniimporter target_link_libraries(openmw-iniimporter
${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
components components
) )

@ -1,16 +1,17 @@
#include "importer.hpp" #include "importer.hpp"
#include <iostream> #include <iostream>
#include <filesystem>
#include <fstream>
#include <components/misc/strings/algorithm.hpp> #include <components/misc/strings/algorithm.hpp>
#include <components/misc/strings/format.hpp> #include <components/misc/strings/format.hpp>
#include <components/misc/strings/lower.hpp> #include <components/misc/strings/lower.hpp>
#include <components/esm3/esmreader.hpp> #include <components/esm3/esmreader.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
namespace bfs = boost::filesystem;
namespace sfs = std::filesystem;
MwIniImporter::MwIniImporter() MwIniImporter::MwIniImporter()
: mVerbose(false) : mVerbose(false)
@ -654,12 +655,12 @@ void MwIniImporter::setVerbose(bool verbose) {
mVerbose = verbose; mVerbose = verbose;
} }
MwIniImporter::multistrmap MwIniImporter::loadIniFile(const boost::filesystem::path& filename) const { MwIniImporter::multistrmap MwIniImporter::loadIniFile(const std::filesystem::path& filename) const {
std::cout << "load ini file: " << filename << std::endl; std::cout << "load ini file: " << filename << std::endl;
std::string section(""); std::string section("");
MwIniImporter::multistrmap map; MwIniImporter::multistrmap map;
bfs::ifstream file((bfs::path(filename))); std::ifstream file((sfs::path(filename)));
ToUTF8::Utf8Encoder encoder(mEncoding); ToUTF8::Utf8Encoder encoder(mEncoding);
std::string line; std::string line;
@ -715,11 +716,11 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const boost::filesystem::p
return map; return map;
} }
MwIniImporter::multistrmap MwIniImporter::loadCfgFile(const boost::filesystem::path& filename) { MwIniImporter::multistrmap MwIniImporter::loadCfgFile(const std::filesystem::path& filename) {
std::cout << "load cfg file: " << filename << std::endl; std::cout << "load cfg file: " << filename << std::endl;
MwIniImporter::multistrmap map; MwIniImporter::multistrmap map;
bfs::ifstream file((bfs::path(filename))); std::ifstream file((sfs::path(filename)));
std::string line; std::string line;
while (std::getline(file, line)) { while (std::getline(file, line)) {
@ -861,7 +862,7 @@ std::vector<std::string>::iterator MwIniImporter::findString(std::vector<std::st
}); });
} }
void MwIniImporter::addPaths(std::vector<boost::filesystem::path>& output, std::vector<std::string> input) { void MwIniImporter::addPaths(std::vector<std::filesystem::path>& output, std::vector<std::string> input) {
for (auto& path : input) for (auto& path : input)
{ {
if (path.front() == '"') if (path.front() == '"')
@ -873,14 +874,14 @@ void MwIniImporter::addPaths(std::vector<boost::filesystem::path>& output, std::
} }
} }
void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini, const boost::filesystem::path& iniFilename) const void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini, const std::filesystem::path& iniFilename) const
{ {
std::vector<std::pair<std::time_t, boost::filesystem::path>> contentFiles; std::vector<std::pair<std::time_t, std::filesystem::path>> contentFiles;
std::string baseGameFile("Game Files:GameFile"); std::string baseGameFile("Game Files:GameFile");
std::time_t defaultTime = 0; std::time_t defaultTime = 0;
ToUTF8::Utf8Encoder encoder(mEncoding); ToUTF8::Utf8Encoder encoder(mEncoding);
std::vector<boost::filesystem::path> dataPaths; std::vector<std::filesystem::path> dataPaths;
if (cfg.count("data")) if (cfg.count("data"))
addPaths(dataPaths, cfg["data"]); addPaths(dataPaths, cfg["data"]);
@ -909,7 +910,7 @@ void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini, co
bool found = false; bool found = false;
for (auto & dataPath : dataPaths) for (auto & dataPath : dataPaths)
{ {
boost::filesystem::path path = dataPath / *entry; std::filesystem::path path = dataPath / *entry;
std::time_t time = lastWriteTime(path, defaultTime); std::time_t time = lastWriteTime(path, defaultTime);
if (time != defaultTime) if (time != defaultTime)
{ {
@ -942,7 +943,7 @@ void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini, co
{ {
dependencies.push_back(gameFile.name); dependencies.push_back(gameFile.name);
} }
unsortedFiles.emplace_back(boost::filesystem::path(reader.getName()).filename().string(), dependencies); unsortedFiles.emplace_back(std::filesystem::path(reader.getName()).filename().string(), dependencies);
reader.close(); reader.close();
} }
@ -983,13 +984,13 @@ void MwIniImporter::setInputEncoding(const ToUTF8::FromType &encoding)
mEncoding = encoding; mEncoding = encoding;
} }
std::time_t MwIniImporter::lastWriteTime(const boost::filesystem::path& filename, std::time_t defaultTime) std::time_t MwIniImporter::lastWriteTime(const std::filesystem::path& filename, std::time_t defaultTime)
{ {
std::time_t writeTime(defaultTime); std::time_t writeTime(defaultTime);
if (boost::filesystem::exists(filename)) if (std::filesystem::exists(filename))
{ {
boost::filesystem::path resolved = boost::filesystem::canonical(filename); std::filesystem::path resolved = std::filesystem::canonical(filename);
writeTime = boost::filesystem::last_write_time(resolved); writeTime = std::chrono::system_clock::to_time_t (Misc::clockCast<std::chrono::system_clock::time_point> (std::filesystem::last_write_time (resolved)));;
// print timestamp // print timestamp
const int size=1024; const int size=1024;

@ -6,7 +6,7 @@
#include <vector> #include <vector>
#include <exception> #include <exception>
#include <iosfwd> #include <iosfwd>
#include <boost/filesystem/path.hpp> #include <filesystem>
#include <components/to_utf8/to_utf8.hpp> #include <components/to_utf8/to_utf8.hpp>
@ -19,12 +19,12 @@ class MwIniImporter {
MwIniImporter(); MwIniImporter();
void setInputEncoding(const ToUTF8::FromType& encoding); void setInputEncoding(const ToUTF8::FromType& encoding);
void setVerbose(bool verbose); void setVerbose(bool verbose);
multistrmap loadIniFile(const boost::filesystem::path& filename) const; multistrmap loadIniFile(const std::filesystem::path& filename) const;
static multistrmap loadCfgFile(const boost::filesystem::path& filename); static multistrmap loadCfgFile(const std::filesystem::path& filename);
void merge(multistrmap &cfg, const multistrmap &ini) const; void merge(multistrmap &cfg, const multistrmap &ini) const;
void mergeFallback(multistrmap &cfg, const multistrmap &ini) const; void mergeFallback(multistrmap &cfg, const multistrmap &ini) const;
void importGameFiles(multistrmap &cfg, const multistrmap &ini, void importGameFiles(multistrmap &cfg, const multistrmap &ini,
const boost::filesystem::path& iniFilename) const; const std::filesystem::path& iniFilename) const;
void importArchives(multistrmap &cfg, const multistrmap &ini) const; void importArchives(multistrmap &cfg, const multistrmap &ini) const;
static void writeToFile(std::ostream &out, const multistrmap &cfg); static void writeToFile(std::ostream &out, const multistrmap &cfg);
@ -35,10 +35,10 @@ class MwIniImporter {
static std::vector<std::string>::iterator findString(std::vector<std::string>& source, const std::string& string); static std::vector<std::string>::iterator findString(std::vector<std::string>& source, const std::string& string);
static void insertMultistrmap(multistrmap &cfg, const std::string& key, const std::string& value); static void insertMultistrmap(multistrmap &cfg, const std::string& key, const std::string& value);
static void addPaths(std::vector<boost::filesystem::path>& output, std::vector<std::string> input); static void addPaths(std::vector<std::filesystem::path>& output, std::vector<std::string> input);
/// \return file's "last modified time", used in original MW to determine plug-in load order /// \return file's "last modified time", used in original MW to determine plug-in load order
static std::time_t lastWriteTime(const boost::filesystem::path& filename, std::time_t defaultTime); static std::time_t lastWriteTime(const std::filesystem::path& filename, std::time_t defaultTime);
bool mVerbose; bool mVerbose;
strmap mMergeMap; strmap mMergeMap;

@ -1,13 +1,13 @@
#include "importer.hpp" #include "importer.hpp"
#include <iostream> #include <iostream>
#include <filesystem>
#include <fstream>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
namespace bpo = boost::program_options; namespace bpo = boost::program_options;
namespace bfs = boost::filesystem; namespace sfs = std::filesystem;
#ifndef _WIN32 #ifndef _WIN32
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
@ -47,12 +47,12 @@ private:
OpenMW application stack assumes UTF-8 encoding, therefore this OpenMW application stack assumes UTF-8 encoding, therefore this
conversion. conversion.
For boost::filesystem::path::imbue see components/files/windowspath.cpp For std::filesystem::path::imbue see components/files/windowspath.cpp
*/ */
int wmain(int argc, wchar_t *wargv[]) { int wmain(int argc, wchar_t *wargv[]) {
utf8argv converter(argc, wargv); utf8argv converter(argc, wargv);
char **argv = converter.get(); char **argv = converter.get();
boost::filesystem::path::imbue(boost::locale::generator().generate("")); std::filesystem::path::imbue(boost::locale::generator().generate(""));
#endif #endif
try try
@ -92,8 +92,8 @@ int wmain(int argc, wchar_t *wargv[]) {
bpo::notify(vm); bpo::notify(vm);
boost::filesystem::path iniFile(vm["ini"].as<std::string>()); std::filesystem::path iniFile(vm["ini"].as<std::string>());
boost::filesystem::path cfgFile(vm["cfg"].as<std::string>()); std::filesystem::path cfgFile(vm["cfg"].as<std::string>());
// if no output is given, write back to cfg file // if no output is given, write back to cfg file
std::string outputFile(vm["output"].as<std::string>()); std::string outputFile(vm["output"].as<std::string>());
@ -101,11 +101,11 @@ int wmain(int argc, wchar_t *wargv[]) {
outputFile = vm["cfg"].as<std::string>(); outputFile = vm["cfg"].as<std::string>();
} }
if(!boost::filesystem::exists(iniFile)) { if(!std::filesystem::exists(iniFile)) {
std::cerr << "ini file does not exist" << std::endl; std::cerr << "ini file does not exist" << std::endl;
return -3; return -3;
} }
if(!boost::filesystem::exists(cfgFile)) if(!std::filesystem::exists(cfgFile))
std::cerr << "cfg file does not exist" << std::endl; std::cerr << "cfg file does not exist" << std::endl;
MwIniImporter importer; MwIniImporter importer;
@ -137,7 +137,7 @@ int wmain(int argc, wchar_t *wargv[]) {
} }
std::cout << "write to: " << outputFile << std::endl; std::cout << "write to: " << outputFile << std::endl;
bfs::ofstream file((bfs::path(outputFile))); std::ofstream file((sfs::path(outputFile)));
importer.writeToFile(file, cfg); importer.writeToFile(file, cfg);
} }
catch (std::exception& e) catch (std::exception& e)

@ -224,8 +224,6 @@ target_link_libraries(openmw-cs
${OSGTEXT_LIBRARIES} ${OSGTEXT_LIBRARIES}
${OSG_LIBRARIES} ${OSG_LIBRARIES}
${EXTERN_OSGQT_LIBRARY} ${EXTERN_OSGQT_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}
components_qt components_qt
) )

@ -63,7 +63,7 @@ CS::Editor::Editor (int argc, char **argv)
connect (&mStartup, &CSVDoc::StartupDialogue::editConfig, this, &Editor::showSettings); connect (&mStartup, &CSVDoc::StartupDialogue::editConfig, this, &Editor::showSettings);
connect (&mFileDialog, &CSVDoc::FileDialog::signalOpenFiles, connect (&mFileDialog, &CSVDoc::FileDialog::signalOpenFiles,
this, [this](const boost::filesystem::path &savePath){ this->openFiles(savePath); }); this, [this](const std::filesystem::path &savePath){ this->openFiles(savePath); });
connect (&mFileDialog, &CSVDoc::FileDialog::signalCreateNewFile, this, &Editor::createNewFile); connect (&mFileDialog, &CSVDoc::FileDialog::signalCreateNewFile, this, &Editor::createNewFile);
connect (&mFileDialog, &CSVDoc::FileDialog::rejected, this, &Editor::cancelFileDialog); connect (&mFileDialog, &CSVDoc::FileDialog::rejected, this, &Editor::cancelFileDialog);
@ -77,7 +77,7 @@ CS::Editor::~Editor ()
mPidFile.close(); mPidFile.close();
if(mServer && boost::filesystem::exists(mPid)) if(mServer && std::filesystem::exists(mPid))
static_cast<void> ( // silence coverity warning static_cast<void> ( // silence coverity warning
remove(mPid.string().c_str())); // ignore any error remove(mPid.string().c_str())); // ignore any error
} }
@ -138,7 +138,7 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
Files::PathContainer::value_type local(variables["data-local"].as<Files::MaybeQuotedPathContainer::value_type>()); Files::PathContainer::value_type local(variables["data-local"].as<Files::MaybeQuotedPathContainer::value_type>());
if (!local.empty()) if (!local.empty())
{ {
boost::filesystem::create_directories(local); std::filesystem::create_directories(local);
dataLocal.push_back(local); dataLocal.push_back(local);
} }
mCfgMgr.filterOutNonExistingPaths(dataDirs); mCfgMgr.filterOutNonExistingPaths(dataDirs);
@ -225,9 +225,9 @@ void CS::Editor::loadDocument()
mFileDialog.showDialog (CSVDoc::ContentAction_Edit); mFileDialog.showDialog (CSVDoc::ContentAction_Edit);
} }
void CS::Editor::openFiles (const boost::filesystem::path &savePath, const std::vector<boost::filesystem::path> &discoveredFiles) void CS::Editor::openFiles (const std::filesystem::path &savePath, const std::vector<std::filesystem::path> &discoveredFiles)
{ {
std::vector<boost::filesystem::path> files; std::vector<std::filesystem::path> files;
if(discoveredFiles.empty()) if(discoveredFiles.empty())
{ {
@ -244,9 +244,9 @@ void CS::Editor::openFiles (const boost::filesystem::path &savePath, const std::
mFileDialog.hide(); mFileDialog.hide();
} }
void CS::Editor::createNewFile (const boost::filesystem::path &savePath) void CS::Editor::createNewFile (const std::filesystem::path &savePath)
{ {
std::vector<boost::filesystem::path> files; std::vector<std::filesystem::path> files;
for (const QString &path : mFileDialog.selectedFilePaths()) { for (const QString &path : mFileDialog.selectedFilePaths()) {
files.emplace_back(path.toUtf8().constData()); files.emplace_back(path.toUtf8().constData());
@ -259,9 +259,9 @@ void CS::Editor::createNewFile (const boost::filesystem::path &savePath)
mFileDialog.hide(); mFileDialog.hide();
} }
void CS::Editor::createNewGame (const boost::filesystem::path& file) void CS::Editor::createNewGame (const std::filesystem::path& file)
{ {
std::vector<boost::filesystem::path> files; std::vector<std::filesystem::path> files;
files.push_back (file); files.push_back (file);
@ -292,9 +292,9 @@ bool CS::Editor::makeIPCServer()
{ {
try try
{ {
mPid = boost::filesystem::temp_directory_path(); mPid = std::filesystem::temp_directory_path();
mPid /= "openmw-cs.pid"; mPid /= "openmw-cs.pid";
bool pidExists = boost::filesystem::exists(mPid); bool pidExists = std::filesystem::exists(mPid);
mPidFile.open(mPid); mPidFile.open(mPid);
@ -321,7 +321,7 @@ bool CS::Editor::makeIPCServer()
mServer->close(); mServer->close();
fullPath.remove(QRegExp("dummy$")); fullPath.remove(QRegExp("dummy$"));
fullPath += mIpcServerName; fullPath += mIpcServerName;
if(boost::filesystem::exists(fullPath.toUtf8().constData())) if(std::filesystem::exists(fullPath.toUtf8().constData()))
{ {
// TODO: compare pid of the current process with that in the file // TODO: compare pid of the current process with that in the file
Log(Debug::Info) << "Detected unclean shutdown."; Log(Debug::Info) << "Detected unclean shutdown.";
@ -376,7 +376,7 @@ int CS::Editor::run()
fileReader.setEncoder(&encoder); fileReader.setEncoder(&encoder);
fileReader.open(mFileToLoad.string()); fileReader.open(mFileToLoad.string());
std::vector<boost::filesystem::path> discoveredFiles; std::vector<std::filesystem::path> discoveredFiles;
for (std::vector<ESM::Header::MasterData>::const_iterator itemIter = fileReader.getGameFiles().begin(); for (std::vector<ESM::Header::MasterData>::const_iterator itemIter = fileReader.getGameFiles().begin();
itemIter != fileReader.getGameFiles().end(); ++itemIter) itemIter != fileReader.getGameFiles().end(); ++itemIter)
@ -384,8 +384,8 @@ int CS::Editor::run()
for (Files::PathContainer::const_iterator pathIter = mDataDirs.begin(); for (Files::PathContainer::const_iterator pathIter = mDataDirs.begin();
pathIter != mDataDirs.end(); ++pathIter) pathIter != mDataDirs.end(); ++pathIter)
{ {
const boost::filesystem::path masterPath = *pathIter / itemIter->name; const std::filesystem::path masterPath = *pathIter / itemIter->name;
if (boost::filesystem::exists(masterPath)) if (std::filesystem::exists(masterPath))
{ {
discoveredFiles.push_back(masterPath); discoveredFiles.push_back(masterPath);
break; break;

@ -1,8 +1,10 @@
#ifndef CS_EDITOR_H #ifndef CS_EDITOR_H
#define CS_EDITOR_H #define CS_EDITOR_H
#include <filesystem>
#include <fstream>
#include <boost/interprocess/sync/file_lock.hpp> #include <boost/interprocess/sync/file_lock.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/program_options/variables_map.hpp> #include <boost/program_options/variables_map.hpp>
#include <QObject> #include <QObject>
@ -48,15 +50,15 @@ namespace CS
CSVDoc::NewGameDialogue mNewGame; CSVDoc::NewGameDialogue mNewGame;
CSVPrefs::Dialogue mSettings; CSVPrefs::Dialogue mSettings;
CSVDoc::FileDialog mFileDialog; CSVDoc::FileDialog mFileDialog;
boost::filesystem::path mLocal; std::filesystem::path mLocal;
boost::filesystem::path mResources; std::filesystem::path mResources;
boost::filesystem::path mPid; std::filesystem::path mPid;
boost::interprocess::file_lock mLock; boost::interprocess::file_lock mLock;
boost::filesystem::ofstream mPidFile; std::ofstream mPidFile;
bool mFsStrict; bool mFsStrict;
CSVTools::Merge mMerge; CSVTools::Merge mMerge;
CSVDoc::ViewManager* mViewManager; CSVDoc::ViewManager* mViewManager;
boost::filesystem::path mFileToLoad; std::filesystem::path mFileToLoad;
Files::PathContainer mDataDirs; Files::PathContainer mDataDirs;
std::string mEncodingName; std::string mEncodingName;
@ -88,9 +90,9 @@ namespace CS
void cancelFileDialog(); void cancelFileDialog();
void loadDocument(); void loadDocument();
void openFiles (const boost::filesystem::path &path, const std::vector<boost::filesystem::path> &discoveredFiles = std::vector<boost::filesystem::path>()); void openFiles (const std::filesystem::path &path, const std::vector<std::filesystem::path> &discoveredFiles = std::vector<std::filesystem::path>());
void createNewFile (const boost::filesystem::path& path); void createNewFile (const std::filesystem::path& path);
void createNewGame (const boost::filesystem::path& file); void createNewGame (const std::filesystem::path& file);
void showStartup(); void showStartup();

@ -4,9 +4,7 @@
#include <cassert> #include <cassert>
#include <memory> #include <memory>
#include <filesystem>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include "../world/defaultgmsts.hpp" #include "../world/defaultgmsts.hpp"
@ -15,6 +13,7 @@
#endif #endif
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <utility>
void CSMDoc::Document::addGmsts() void CSMDoc::Document::addGmsts()
{ {
@ -277,11 +276,11 @@ void CSMDoc::Document::createBase()
} }
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration, CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
const std::vector< boost::filesystem::path >& files,bool new_, std::vector< std::filesystem::path > files,bool new_,
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir, const std::filesystem::path& savePath, const std::filesystem::path& resDir,
ToUTF8::FromType encoding, const std::vector<std::string>& blacklistedScripts, ToUTF8::FromType encoding, const std::vector<std::string>& blacklistedScripts,
bool fsStrict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives) bool fsStrict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives)
: mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding, fsStrict, dataPaths, archives, resDir), : mSavePath (savePath), mContentFiles (std::move(files)), mNew (new_), mData (encoding, fsStrict, dataPaths, archives, resDir),
mTools (*this, encoding), mTools (*this, encoding),
mProjectPath ((configuration.getUserDataPath() / "projects") / mProjectPath ((configuration.getUserDataPath() / "projects") /
(savePath.filename().string() + ".project")), (savePath.filename().string() + ".project")),
@ -293,19 +292,19 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
if (mContentFiles.empty()) if (mContentFiles.empty())
throw std::runtime_error ("Empty content file sequence"); throw std::runtime_error ("Empty content file sequence");
if (mNew || !boost::filesystem::exists (mProjectPath)) if (mNew || !std::filesystem::exists (mProjectPath))
{ {
boost::filesystem::path filtersPath (configuration.getUserDataPath() / "defaultfilters"); std::filesystem::path filtersPath (configuration.getUserDataPath() / "defaultfilters");
boost::filesystem::ofstream destination(mProjectPath, std::ios::out | std::ios::binary); std::ofstream destination(mProjectPath, std::ios::out | std::ios::binary);
if (!destination.is_open()) if (!destination.is_open())
throw std::runtime_error("Can not create project file: " + mProjectPath.string()); throw std::runtime_error("Can not create project file: " + mProjectPath.string());
destination.exceptions(std::ios::failbit | std::ios::badbit); destination.exceptions(std::ios::failbit | std::ios::badbit);
if (!boost::filesystem::exists (filtersPath)) if (!std::filesystem::exists (filtersPath))
filtersPath = mResDir / "defaultfilters"; filtersPath = mResDir / "defaultfilters";
boost::filesystem::ifstream source(filtersPath, std::ios::in | std::ios::binary); std::ifstream source(filtersPath, std::ios::in | std::ios::binary);
if (!source.is_open()) if (!source.is_open())
throw std::runtime_error("Can not read filters file: " + filtersPath.string()); throw std::runtime_error("Can not read filters file: " + filtersPath.string());
source.exceptions(std::ios::failbit | std::ios::badbit); source.exceptions(std::ios::failbit | std::ios::badbit);
@ -369,22 +368,22 @@ int CSMDoc::Document::getState() const
return state; return state;
} }
const boost::filesystem::path& CSMDoc::Document::getResourceDir() const const std::filesystem::path& CSMDoc::Document::getResourceDir() const
{ {
return mResDir; return mResDir;
} }
const boost::filesystem::path& CSMDoc::Document::getSavePath() const const std::filesystem::path& CSMDoc::Document::getSavePath() const
{ {
return mSavePath; return mSavePath;
} }
const boost::filesystem::path& CSMDoc::Document::getProjectPath() const const std::filesystem::path& CSMDoc::Document::getProjectPath() const
{ {
return mProjectPath; return mProjectPath;
} }
const std::vector<boost::filesystem::path>& CSMDoc::Document::getContentFiles() const const std::vector<std::filesystem::path>& CSMDoc::Document::getContentFiles() const
{ {
return mContentFiles; return mContentFiles;
} }
@ -483,7 +482,7 @@ void CSMDoc::Document::startRunning (const std::string& profile,
{ {
std::vector<std::string> contentFiles; std::vector<std::string> contentFiles;
for (std::vector<boost::filesystem::path>::const_iterator iter (mContentFiles.begin()); for (std::vector<std::filesystem::path>::const_iterator iter (mContentFiles.begin());
iter!=mContentFiles.end(); ++iter) iter!=mContentFiles.end(); ++iter)
contentFiles.push_back (iter->filename().string()); contentFiles.push_back (iter->filename().string());

@ -2,8 +2,7 @@
#define CSM_DOC_DOCUMENT_H #define CSM_DOC_DOCUMENT_H
#include <string> #include <string>
#include <filesystem>
#include <boost/filesystem/path.hpp>
#include <QUndoStack> #include <QUndoStack>
#include <QObject> #include <QObject>
@ -58,15 +57,15 @@ namespace CSMDoc
private: private:
boost::filesystem::path mSavePath; std::filesystem::path mSavePath;
std::vector<boost::filesystem::path> mContentFiles; std::vector<std::filesystem::path> mContentFiles;
bool mNew; bool mNew;
CSMWorld::Data mData; CSMWorld::Data mData;
CSMTools::Tools mTools; CSMTools::Tools mTools;
boost::filesystem::path mProjectPath; std::filesystem::path mProjectPath;
Saving mSavingOperation; Saving mSavingOperation;
OperationHolder mSaving; OperationHolder mSaving;
boost::filesystem::path mResDir; std::filesystem::path mResDir;
Blacklist mBlacklist; Blacklist mBlacklist;
Runner mRunner; Runner mRunner;
bool mDirty; bool mDirty;
@ -100,8 +99,8 @@ namespace CSMDoc
public: public:
Document (const Files::ConfigurationManager& configuration, Document (const Files::ConfigurationManager& configuration,
const std::vector< boost::filesystem::path >& files, bool new_, std::vector< std::filesystem::path > files, bool new_,
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir, const std::filesystem::path& savePath, const std::filesystem::path& resDir,
ToUTF8::FromType encoding, const std::vector<std::string>& blacklistedScripts, ToUTF8::FromType encoding, const std::vector<std::string>& blacklistedScripts,
bool fsStrict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives); bool fsStrict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives);
@ -111,13 +110,13 @@ namespace CSMDoc
int getState() const; int getState() const;
const boost::filesystem::path& getResourceDir() const; const std::filesystem::path& getResourceDir() const;
const boost::filesystem::path& getSavePath() const; const std::filesystem::path& getSavePath() const;
const boost::filesystem::path& getProjectPath() const; const std::filesystem::path& getProjectPath() const;
const std::vector<boost::filesystem::path>& getContentFiles() const; const std::vector<std::filesystem::path>& getContentFiles() const;
///< \attention The last element in this collection is the file that is being edited, ///< \attention The last element in this collection is the file that is being edited,
/// but with its original path instead of the save path. /// but with its original path instead of the save path.

@ -1,6 +1,6 @@
#include "documentmanager.hpp" #include "documentmanager.hpp"
#include <boost/filesystem.hpp> #include <filesystem>
#ifndef Q_MOC_RUN #ifndef Q_MOC_RUN
#include <components/files/configurationmanager.hpp> #include <components/files/configurationmanager.hpp>
@ -11,10 +11,10 @@
CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration) CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration)
: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252), mFsStrict(false) : mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252), mFsStrict(false)
{ {
boost::filesystem::path projectPath = configuration.getUserDataPath() / "projects"; std::filesystem::path projectPath = configuration.getUserDataPath() / "projects";
if (!boost::filesystem::is_directory (projectPath)) if (!std::filesystem::is_directory (projectPath))
boost::filesystem::create_directories (projectPath); std::filesystem::create_directories (projectPath);
mLoader.moveToThread (&mLoaderThread); mLoader.moveToThread (&mLoaderThread);
mLoaderThread.start(); mLoaderThread.start();
@ -51,7 +51,7 @@ bool CSMDoc::DocumentManager::isEmpty()
return mDocuments.empty(); return mDocuments.empty();
} }
void CSMDoc::DocumentManager::addDocument (const std::vector<boost::filesystem::path>& files, const boost::filesystem::path& savePath, void CSMDoc::DocumentManager::addDocument (const std::vector<std::filesystem::path>& files, const std::filesystem::path& savePath,
bool new_) bool new_)
{ {
Document *document = makeDocument (files, savePath, new_); Document *document = makeDocument (files, savePath, new_);
@ -59,8 +59,8 @@ void CSMDoc::DocumentManager::addDocument (const std::vector<boost::filesystem::
} }
CSMDoc::Document *CSMDoc::DocumentManager::makeDocument ( CSMDoc::Document *CSMDoc::DocumentManager::makeDocument (
const std::vector< boost::filesystem::path >& files, const std::vector< std::filesystem::path >& files,
const boost::filesystem::path& savePath, bool new_) const std::filesystem::path& savePath, bool new_)
{ {
return new Document (mConfiguration, files, new_, savePath, mResDir, mEncoding, mBlacklistedScripts, mFsStrict, mDataPaths, mArchives); return new Document (mConfiguration, files, new_, savePath, mResDir, mEncoding, mBlacklistedScripts, mFsStrict, mDataPaths, mArchives);
} }
@ -93,9 +93,9 @@ void CSMDoc::DocumentManager::removeDocument (CSMDoc::Document *document)
emit lastDocumentDeleted(); emit lastDocumentDeleted();
} }
void CSMDoc::DocumentManager::setResourceDir (const boost::filesystem::path& parResDir) void CSMDoc::DocumentManager::setResourceDir (const std::filesystem::path& parResDir)
{ {
mResDir = boost::filesystem::system_complete(parResDir); mResDir = std::filesystem::absolute(parResDir);
} }
void CSMDoc::DocumentManager::setEncoding (ToUTF8::FromType encoding) void CSMDoc::DocumentManager::setEncoding (ToUTF8::FromType encoding)

@ -3,8 +3,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <filesystem>
#include <boost/filesystem/path.hpp>
#include <QObject> #include <QObject>
#include <QThread> #include <QThread>
@ -40,7 +39,7 @@ namespace CSMDoc
ToUTF8::FromType mEncoding; ToUTF8::FromType mEncoding;
std::vector<std::string> mBlacklistedScripts; std::vector<std::string> mBlacklistedScripts;
boost::filesystem::path mResDir; std::filesystem::path mResDir;
bool mFsStrict; bool mFsStrict;
Files::PathContainer mDataPaths; Files::PathContainer mDataPaths;
@ -55,8 +54,8 @@ namespace CSMDoc
~DocumentManager(); ~DocumentManager();
void addDocument (const std::vector< boost::filesystem::path >& files, void addDocument (const std::vector< std::filesystem::path >& files,
const boost::filesystem::path& savePath, bool new_); const std::filesystem::path& savePath, bool new_);
///< \param new_ Do not load the last content file in \a files and instead create in an ///< \param new_ Do not load the last content file in \a files and instead create in an
/// appropriate way. /// appropriate way.
@ -66,10 +65,10 @@ namespace CSMDoc
/// ///
/// \param new_ Do not load the last content file in \a files and instead create in an /// \param new_ Do not load the last content file in \a files and instead create in an
/// appropriate way. /// appropriate way.
Document *makeDocument (const std::vector< boost::filesystem::path >& files, Document *makeDocument (const std::vector< std::filesystem::path >& files,
const boost::filesystem::path& savePath, bool new_); const std::filesystem::path& savePath, bool new_);
void setResourceDir (const boost::filesystem::path& parResDir); void setResourceDir (const std::filesystem::path& parResDir);
void setEncoding (ToUTF8::FromType encoding); void setEncoding (ToUTF8::FromType encoding);

@ -87,7 +87,7 @@ void CSMDoc::Loader::load()
if (iter->second.mFile<size) // start loading the files if (iter->second.mFile<size) // start loading the files
{ {
boost::filesystem::path path = document->getContentFiles()[iter->second.mFile]; std::filesystem::path path = document->getContentFiles()[iter->second.mFile];
int steps = document->getData().startLoading (path, iter->second.mFile!=editedIndex, /*project*/false); int steps = document->getData().startLoading (path, iter->second.mFile!=editedIndex, /*project*/false);
iter->second.mRecordsLeft = true; iter->second.mRecordsLeft = true;

@ -1,5 +1,7 @@
#include "runner.hpp" #include "runner.hpp"
#include <utility>
#include <QDir> #include <QDir>
#include <QTemporaryFile> #include <QTemporaryFile>
#include <QTextStream> #include <QTextStream>
@ -7,8 +9,8 @@
#include "operationholder.hpp" #include "operationholder.hpp"
CSMDoc::Runner::Runner (const boost::filesystem::path& projectPath) CSMDoc::Runner::Runner (std::filesystem::path projectPath)
: mRunning (false), mStartup (nullptr), mProjectPath (projectPath) : mRunning (false), mStartup (nullptr), mProjectPath (std::move(projectPath))
{ {
connect (&mProcess, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), connect (&mProcess, qOverload<int, QProcess::ExitStatus>(&QProcess::finished),
this, &Runner::finished); this, &Runner::finished);

@ -3,8 +3,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <filesystem>
#include <boost/filesystem/path.hpp>
#include <QObject> #include <QObject>
#include <QProcess> #include <QProcess>
@ -29,11 +28,11 @@ namespace CSMDoc
std::string mStartupInstruction; std::string mStartupInstruction;
QTemporaryFile *mStartup; QTemporaryFile *mStartup;
QTextDocument mLog; QTextDocument mLog;
boost::filesystem::path mProjectPath; std::filesystem::path mProjectPath;
public: public:
Runner (const boost::filesystem::path& projectPath); Runner (std::filesystem::path projectPath);
~Runner(); ~Runner();

@ -7,7 +7,7 @@
#include "savingstages.hpp" #include "savingstages.hpp"
#include "document.hpp" #include "document.hpp"
CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& projectPath, CSMDoc::Saving::Saving (Document& document, const std::filesystem::path& projectPath,
ToUTF8::FromType encoding) ToUTF8::FromType encoding)
: Operation (State_Saving, true, true), mDocument (document), mState (*this, projectPath, encoding) : Operation (State_Saving, true, true), mDocument (document), mState (*this, projectPath, encoding)
{ {

@ -1,7 +1,7 @@
#ifndef CSM_DOC_SAVING_H #ifndef CSM_DOC_SAVING_H
#define CSM_DOC_SAVING_H #define CSM_DOC_SAVING_H
#include <boost/filesystem/path.hpp> #include <filesystem>
#include <components/to_utf8/to_utf8.hpp> #include <components/to_utf8/to_utf8.hpp>
@ -21,7 +21,7 @@ namespace CSMDoc
public: public:
Saving (Document& document, const boost::filesystem::path& projectPath, Saving (Document& document, const std::filesystem::path& projectPath,
ToUTF8::FromType encoding); ToUTF8::FromType encoding);
}; };

@ -1,8 +1,7 @@
#include "savingstages.hpp" #include "savingstages.hpp"
#include <sstream> #include <sstream>
#include <filesystem>
#include <boost/filesystem.hpp>
#include <components/esm3/loaddial.hpp> #include <components/esm3/loaddial.hpp>
@ -67,14 +66,14 @@ void CSMDoc::WriteHeaderStage::perform (int stage, Messages& messages)
mDocument.getData().count (CSMWorld::RecordBase::State_Deleted)); mDocument.getData().count (CSMWorld::RecordBase::State_Deleted));
/// \todo refine dependency list (at least remove redundant dependencies) /// \todo refine dependency list (at least remove redundant dependencies)
std::vector<boost::filesystem::path> dependencies = mDocument.getContentFiles(); std::vector<std::filesystem::path> dependencies = mDocument.getContentFiles();
std::vector<boost::filesystem::path>::const_iterator end (--dependencies.end()); std::vector<std::filesystem::path>::const_iterator end (--dependencies.end());
for (std::vector<boost::filesystem::path>::const_iterator iter (dependencies.begin()); for (std::vector<std::filesystem::path>::const_iterator iter (dependencies.begin());
iter!=end; ++iter) iter!=end; ++iter)
{ {
std::string name = iter->filename().string(); std::string name = iter->filename().string();
uint64_t size = boost::filesystem::file_size (*iter); uint64_t size = std::filesystem::file_size (*iter);
mState.getWriter().addMaster (name, size); mState.getWriter().addMaster (name, size);
} }
@ -519,15 +518,15 @@ void CSMDoc::FinalSavingStage::perform (int stage, Messages& messages)
mState.getWriter().close(); mState.getWriter().close();
mState.getStream().close(); mState.getStream().close();
if (boost::filesystem::exists (mState.getTmpPath())) if (std::filesystem::exists (mState.getTmpPath()))
boost::filesystem::remove (mState.getTmpPath()); std::filesystem::remove (mState.getTmpPath());
} }
else if (!mState.isProjectFile()) else if (!mState.isProjectFile())
{ {
if (boost::filesystem::exists (mState.getPath())) if (std::filesystem::exists (mState.getPath()))
boost::filesystem::remove (mState.getPath()); std::filesystem::remove (mState.getPath());
boost::filesystem::rename (mState.getTmpPath(), mState.getPath()); std::filesystem::rename (mState.getTmpPath(), mState.getPath());
mDocument.getUndoStack().setClean(); mDocument.getUndoStack().setClean();
} }

@ -1,13 +1,14 @@
#include "savingstate.hpp" #include "savingstate.hpp"
#include <boost/filesystem/fstream.hpp> #include <filesystem>
#include <utility>
#include "operation.hpp" #include "operation.hpp"
#include "document.hpp" #include "document.hpp"
CSMDoc::SavingState::SavingState (Operation& operation, const boost::filesystem::path& projectPath, CSMDoc::SavingState::SavingState (Operation& operation, std::filesystem::path projectPath,
ToUTF8::FromType encoding) ToUTF8::FromType encoding)
: mOperation (operation), mEncoder (encoding), mProjectPath (projectPath), mProjectFile (false) : mOperation (operation), mEncoder (encoding), mProjectPath (std::move(projectPath)), mProjectFile (false)
{ {
mWriter.setEncoder (&mEncoder); mWriter.setEncoder (&mEncoder);
} }
@ -33,24 +34,24 @@ void CSMDoc::SavingState::start (Document& document, bool project)
else else
mPath = document.getSavePath(); mPath = document.getSavePath();
boost::filesystem::path file (mPath.filename().string() + ".tmp"); std::filesystem::path file (mPath.filename().string() + ".tmp");
mTmpPath = mPath.parent_path(); mTmpPath = mPath.parent_path();
mTmpPath /= file; mTmpPath /= file;
} }
const boost::filesystem::path& CSMDoc::SavingState::getPath() const const std::filesystem::path& CSMDoc::SavingState::getPath() const
{ {
return mPath; return mPath;
} }
const boost::filesystem::path& CSMDoc::SavingState::getTmpPath() const const std::filesystem::path& CSMDoc::SavingState::getTmpPath() const
{ {
return mTmpPath; return mTmpPath;
} }
boost::filesystem::ofstream& CSMDoc::SavingState::getStream() std::ofstream& CSMDoc::SavingState::getStream()
{ {
return mStream; return mStream;
} }

@ -4,9 +4,7 @@
#include <fstream> #include <fstream>
#include <map> #include <map>
#include <deque> #include <deque>
#include <filesystem>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/fstream.hpp>
#include <components/esm3/esmwriter.hpp> #include <components/esm3/esmwriter.hpp>
@ -20,18 +18,18 @@ namespace CSMDoc
class SavingState class SavingState
{ {
Operation& mOperation; Operation& mOperation;
boost::filesystem::path mPath; std::filesystem::path mPath;
boost::filesystem::path mTmpPath; std::filesystem::path mTmpPath;
ToUTF8::Utf8Encoder mEncoder; ToUTF8::Utf8Encoder mEncoder;
boost::filesystem::ofstream mStream; std::ofstream mStream;
ESM::ESMWriter mWriter; ESM::ESMWriter mWriter;
boost::filesystem::path mProjectPath; std::filesystem::path mProjectPath;
bool mProjectFile; bool mProjectFile;
std::map<std::string, std::deque<int> > mSubRecords; // record ID, list of subrecords std::map<std::string, std::deque<int> > mSubRecords; // record ID, list of subrecords
public: public:
SavingState (Operation& operation, const boost::filesystem::path& projectPath, SavingState (Operation& operation, std::filesystem::path projectPath,
ToUTF8::FromType encoding); ToUTF8::FromType encoding);
bool hasError() const; bool hasError() const;
@ -39,11 +37,11 @@ namespace CSMDoc
void start (Document& document, bool project); void start (Document& document, bool project);
///< \param project Save project file instead of content file. ///< \param project Save project file instead of content file.
const boost::filesystem::path& getPath() const; const std::filesystem::path& getPath() const;
const boost::filesystem::path& getTmpPath() const; const std::filesystem::path& getTmpPath() const;
boost::filesystem::ofstream& getStream(); std::ofstream& getStream();
ESM::ESMWriter& getWriter(); ESM::ESMWriter& getWriter();

@ -648,7 +648,7 @@ CSMPrefs::State::~State()
void CSMPrefs::State::save() void CSMPrefs::State::save()
{ {
boost::filesystem::path user = mConfigurationManager.getUserConfigPath() / mConfigFile; std::filesystem::path user = mConfigurationManager.getUserConfigPath() / mConfigFile;
Settings::Manager::saveUser (user.string()); Settings::Manager::saveUser (user.string());
} }

@ -40,7 +40,7 @@ void CSMTools::FinishMergedDocumentStage::perform (int stage, CSMDoc::Messages&
// We know that the content file list contains at least two entries and that the first one // We know that the content file list contains at least two entries and that the first one
// does exist on disc (otherwise it would have been impossible to initiate a merge on that // does exist on disc (otherwise it would have been impossible to initiate a merge on that
// document). // document).
boost::filesystem::path path = mState.mSource.getContentFiles()[0]; std::filesystem::path path = mState.mSource.getContentFiles()[0];
ESM::ESMReader reader; ESM::ESMReader reader;
reader.setEncoder (&mEncoder); reader.setEncoder (&mEncoder);

@ -3,13 +3,12 @@
#include <memory> #include <memory>
#include <map> #include <map>
#include <filesystem>
#include <components/to_utf8/to_utf8.hpp> #include <components/to_utf8/to_utf8.hpp>
#include <QObject> #include <QObject>
#include <boost/filesystem/path.hpp>
#include "../doc/operationholder.hpp" #include "../doc/operationholder.hpp"
namespace CSMWorld namespace CSMWorld

@ -64,7 +64,7 @@ int CSMWorld::Data::count (RecordBase::State state, const CollectionBase& collec
} }
CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths, CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths,
const std::vector<std::string>& archives, const boost::filesystem::path& resDir) const std::vector<std::string>& archives, const std::filesystem::path& resDir)
: mEncoder (encoding), mPathgrids (mCells), mRefs (mCells), : mEncoder (encoding), mPathgrids (mCells), mRefs (mCells),
mReader (nullptr), mDialogue (nullptr), mReaderIndex(1), mReader (nullptr), mDialogue (nullptr), mReaderIndex(1),
mFsStrict(fsStrict), mDataPaths(dataPaths), mArchives(archives) mFsStrict(fsStrict), mDataPaths(dataPaths), mArchives(archives)
@ -958,7 +958,7 @@ void CSMWorld::Data::merge()
mGlobals.merge(); mGlobals.merge();
} }
int CSMWorld::Data::getTotalRecords (const std::vector<boost::filesystem::path>& files) int CSMWorld::Data::getTotalRecords (const std::vector<std::filesystem::path>& files)
{ {
int records = 0; int records = 0;
@ -966,7 +966,7 @@ int CSMWorld::Data::getTotalRecords (const std::vector<boost::filesystem::path>&
for (unsigned int i = 0; i < files.size(); ++i) for (unsigned int i = 0; i < files.size(); ++i)
{ {
if (!boost::filesystem::exists(files[i])) if (!std::filesystem::exists(files[i]))
continue; continue;
reader->open(files[i].string()); reader->open(files[i].string());
@ -977,7 +977,7 @@ int CSMWorld::Data::getTotalRecords (const std::vector<boost::filesystem::path>&
return records; return records;
} }
int CSMWorld::Data::startLoading (const boost::filesystem::path& path, bool base, bool project) int CSMWorld::Data::startLoading (const std::filesystem::path& path, bool base, bool project)
{ {
// Don't delete the Reader yet. Some record types store a reference to the Reader to handle on-demand loading // Don't delete the Reader yet. Some record types store a reference to the Reader to handle on-demand loading
std::shared_ptr<ESM::ESMReader> ptr(mReader); std::shared_ptr<ESM::ESMReader> ptr(mReader);

@ -3,8 +3,7 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include <filesystem>
#include <boost/filesystem/path.hpp>
#include <QObject> #include <QObject>
#include <QModelIndex> #include <QModelIndex>
@ -148,7 +147,7 @@ namespace CSMWorld
public: public:
Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths, Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths,
const std::vector<std::string>& archives, const boost::filesystem::path& resDir); const std::vector<std::string>& archives, const std::filesystem::path& resDir);
~Data() override; ~Data() override;
@ -290,9 +289,9 @@ namespace CSMWorld
void merge(); void merge();
///< Merge modified into base. ///< Merge modified into base.
int getTotalRecords (const std::vector<boost::filesystem::path>& files); // for better loading bar int getTotalRecords (const std::vector<std::filesystem::path>& files); // for better loading bar
int startLoading (const boost::filesystem::path& path, bool base, bool project); int startLoading (const std::filesystem::path& path, bool base, bool project);
///< Begin merging content of a file into base or modified. ///< Begin merging content of a file into base or modified.
/// ///
/// \param project load project file instead of content file /// \param project load project file instead of content file

@ -1,9 +1,8 @@
#include "adjusterwidget.hpp" #include "adjusterwidget.hpp"
#include <filesystem>
#include <components/misc/strings/lower.hpp> #include <components/misc/strings/lower.hpp>
#include <boost/filesystem.hpp>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLabel> #include <QLabel>
#include <QStyle> #include <QStyle>
@ -33,12 +32,12 @@ void CSVDoc::AdjusterWidget::setAction (ContentAction action)
mAction = action; mAction = action;
} }
void CSVDoc::AdjusterWidget::setLocalData (const boost::filesystem::path& localData) void CSVDoc::AdjusterWidget::setLocalData (const std::filesystem::path& localData)
{ {
mLocalData = localData; mLocalData = localData;
} }
boost::filesystem::path CSVDoc::AdjusterWidget::getPath() const std::filesystem::path CSVDoc::AdjusterWidget::getPath() const
{ {
if (!mValid) if (!mValid)
throw std::logic_error ("invalid content file path"); throw std::logic_error ("invalid content file path");
@ -69,7 +68,7 @@ void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon)
} }
else else
{ {
boost::filesystem::path path (name.toUtf8().data()); std::filesystem::path path (name.toUtf8().data());
std::string extension = Misc::StringUtils::lowerCase(path.extension().string()); std::string extension = Misc::StringUtils::lowerCase(path.extension().string());
@ -99,7 +98,7 @@ void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon)
message = QString::fromUtf8 (("Will be saved as: " + path.string()).c_str()); message = QString::fromUtf8 (("Will be saved as: " + path.string()).c_str());
mResultPath = path; mResultPath = path;
if (boost::filesystem::exists (path)) if (std::filesystem::exists (path))
{ {
/// \todo add an user setting to make this an error. /// \todo add an user setting to make this an error.
message += "<p>A file with the same name already exists. If you continue, it will be overwritten."; message += "<p>A file with the same name already exists. If you continue, it will be overwritten.";

@ -1,7 +1,7 @@
#ifndef CSV_DOC_ADJUSTERWIDGET_H #ifndef CSV_DOC_ADJUSTERWIDGET_H
#define CSV_DOC_ADJUSTERWIDGET_H #define CSV_DOC_ADJUSTERWIDGET_H
#include <boost/filesystem/path.hpp> #include <filesystem>
#include <QWidget> #include <QWidget>
@ -22,11 +22,11 @@ namespace CSVDoc
public: public:
boost::filesystem::path mLocalData; std::filesystem::path mLocalData;
QLabel *mMessage; QLabel *mMessage;
QLabel *mIcon; QLabel *mIcon;
bool mValid; bool mValid;
boost::filesystem::path mResultPath; std::filesystem::path mResultPath;
ContentAction mAction; ContentAction mAction;
bool mDoFilenameCheck; bool mDoFilenameCheck;
@ -34,13 +34,13 @@ namespace CSVDoc
AdjusterWidget (QWidget *parent = nullptr); AdjusterWidget (QWidget *parent = nullptr);
void setLocalData (const boost::filesystem::path& localData); void setLocalData (const std::filesystem::path& localData);
void setAction (ContentAction action); void setAction (ContentAction action);
void setFilenameCheck (bool doCheck); void setFilenameCheck (bool doCheck);
bool isValid() const; bool isValid() const;
boost::filesystem::path getPath() const; std::filesystem::path getPath() const;
///< This function must not be called if there is no valid path. ///< This function must not be called if there is no valid path.
public slots: public slots:

@ -20,7 +20,7 @@ CSVDoc::FileDialog::FileDialog(QWidget *parent) :
mAdjusterWidget = new AdjusterWidget (this); mAdjusterWidget = new AdjusterWidget (this);
} }
void CSVDoc::FileDialog::addFiles(const std::vector<boost::filesystem::path>& dataDirs) void CSVDoc::FileDialog::addFiles(const std::vector<std::filesystem::path>& dataDirs)
{ {
for (auto iter = dataDirs.rbegin(); iter != dataDirs.rend(); ++iter) for (auto iter = dataDirs.rbegin(); iter != dataDirs.rend(); ++iter)
{ {
@ -50,7 +50,7 @@ QStringList CSVDoc::FileDialog::selectedFilePaths()
return filePaths; return filePaths;
} }
void CSVDoc::FileDialog::setLocalData (const boost::filesystem::path& localData) void CSVDoc::FileDialog::setLocalData (const std::filesystem::path& localData)
{ {
mAdjusterWidget->setLocalData (localData); mAdjusterWidget->setLocalData (localData);
} }

@ -6,12 +6,12 @@
#ifndef Q_MOC_RUN #ifndef Q_MOC_RUN
#include <boost/filesystem/path.hpp> #include <filesystem>
#include "adjusterwidget.hpp" #include "adjusterwidget.hpp"
#ifndef CS_QT_BOOST_FILESYSTEM_PATH_DECLARED #ifndef CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
#define CS_QT_BOOST_FILESYSTEM_PATH_DECLARED #define CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
Q_DECLARE_METATYPE (boost::filesystem::path) Q_DECLARE_METATYPE (std::filesystem::path)
#endif #endif
#endif #endif
@ -45,14 +45,14 @@ namespace CSVDoc
explicit FileDialog(QWidget *parent = nullptr); explicit FileDialog(QWidget *parent = nullptr);
void showDialog (ContentAction action); void showDialog (ContentAction action);
void addFiles(const std::vector<boost::filesystem::path>& dataDirs); void addFiles(const std::vector<std::filesystem::path>& dataDirs);
void setEncoding (const QString &encoding); void setEncoding (const QString &encoding);
void clearFiles (); void clearFiles ();
QString filename() const; QString filename() const;
QStringList selectedFilePaths(); QStringList selectedFilePaths();
void setLocalData (const boost::filesystem::path& localData); void setLocalData (const std::filesystem::path& localData);
private: private:
@ -61,8 +61,8 @@ namespace CSVDoc
signals: signals:
void signalOpenFiles (const boost::filesystem::path &path); void signalOpenFiles (const std::filesystem::path &path);
void signalCreateNewFile (const boost::filesystem::path &path); void signalCreateNewFile (const std::filesystem::path &path);
void signalUpdateAcceptButton (bool, int); void signalUpdateAcceptButton (bool, int);

@ -50,7 +50,7 @@ CSVDoc::NewGameDialogue::NewGameDialogue()
move (scr.center().x() - rect.center().x(), scr.center().y() - rect.center().y()); move (scr.center().x() - rect.center().x(), scr.center().y() - rect.center().y());
} }
void CSVDoc::NewGameDialogue::setLocalData (const boost::filesystem::path& localData) void CSVDoc::NewGameDialogue::setLocalData (const std::filesystem::path& localData)
{ {
mAdjusterWidget->setLocalData (localData); mAdjusterWidget->setLocalData (localData);
} }

@ -1,14 +1,14 @@
#ifndef CSV_DOC_NEWGAME_H #ifndef CSV_DOC_NEWGAME_H
#define CSV_DOC_NEWGAME_H #define CSV_DOC_NEWGAME_H
#include <boost/filesystem/path.hpp> #include <filesystem>
#include <QDialog> #include <QDialog>
#include <QMetaType> #include <QMetaType>
#ifndef CS_QT_BOOST_FILESYSTEM_PATH_DECLARED #ifndef CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
#define CS_QT_BOOST_FILESYSTEM_PATH_DECLARED #define CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
Q_DECLARE_METATYPE (boost::filesystem::path) Q_DECLARE_METATYPE (std::filesystem::path)
#endif #endif
class QPushButton; class QPushButton;
@ -30,11 +30,11 @@ namespace CSVDoc
NewGameDialogue(); NewGameDialogue();
void setLocalData (const boost::filesystem::path& localData); void setLocalData (const std::filesystem::path& localData);
signals: signals:
void createRequest (const boost::filesystem::path& file); void createRequest (const std::filesystem::path& file);
void cancelCreateGame (); void cancelCreateGame ();

@ -98,14 +98,14 @@ void CSVTools::Merge::configure (CSMDoc::Document *document)
while (mFiles->count()) while (mFiles->count())
delete mFiles->takeItem (0); delete mFiles->takeItem (0);
std::vector<boost::filesystem::path> files = document->getContentFiles(); std::vector<std::filesystem::path> files = document->getContentFiles();
for (std::vector<boost::filesystem::path>::const_iterator iter (files.begin()); for (std::vector<std::filesystem::path>::const_iterator iter (files.begin());
iter!=files.end(); ++iter) iter!=files.end(); ++iter)
mFiles->addItem (QString::fromUtf8 (iter->filename().string().c_str())); mFiles->addItem (QString::fromUtf8 (iter->filename().string().c_str()));
} }
void CSVTools::Merge::setLocalData (const boost::filesystem::path& localData) void CSVTools::Merge::setLocalData (const std::filesystem::path& localData)
{ {
mAdjuster->setLocalData (localData); mAdjuster->setLocalData (localData);
} }
@ -125,7 +125,7 @@ void CSVTools::Merge::accept()
{ {
if ((mDocument->getState() & CSMDoc::State_Merging)==0) if ((mDocument->getState() & CSMDoc::State_Merging)==0)
{ {
std::vector< boost::filesystem::path > files (1, mAdjuster->getPath()); std::vector< std::filesystem::path > files (1, mAdjuster->getPath());
std::unique_ptr<CSMDoc::Document> target ( std::unique_ptr<CSMDoc::Document> target (
mDocumentManager.makeDocument (files, files[0], true)); mDocumentManager.makeDocument (files, files[0], true));

@ -4,7 +4,7 @@
#include <QWidget> #include <QWidget>
#ifndef Q_MOC_RUN #ifndef Q_MOC_RUN
#include <boost/filesystem/path.hpp> #include <filesystem>
#endif #endif
class QPushButton; class QPushButton;
@ -44,7 +44,7 @@ namespace CSVTools
/// Configure dialogue for a new merge /// Configure dialogue for a new merge
void configure (CSMDoc::Document *document); void configure (CSMDoc::Document *document);
void setLocalData (const boost::filesystem::path& localData); void setLocalData (const std::filesystem::path& localData);
CSMDoc::Document *getDocument() const; CSMDoc::Document *getDocument() const;

@ -143,9 +143,6 @@ target_link_libraries(openmw
${OSGDB_LIBRARIES} ${OSGDB_LIBRARIES}
${OSGUTIL_LIBRARIES} ${OSGUTIL_LIBRARIES}
${OSG_LIBRARIES} ${OSG_LIBRARIES}
${Boost_SYSTEM_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}
${OPENAL_LIBRARY} ${OPENAL_LIBRARY}
${FFmpeg_LIBRARIES} ${FFmpeg_LIBRARIES}

@ -1,11 +1,7 @@
#include "engine.hpp" #include "engine.hpp"
#include <iomanip>
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include <filesystem>
#include <boost/filesystem/fstream.hpp>
#include <osgViewer/ViewerEventHandlers> #include <osgViewer/ViewerEventHandlers>
#include <osgDB/WriteFile> #include <osgDB/WriteFile>
@ -542,7 +538,7 @@ void OMW::Engine::addArchive (const std::string& archive) {
} }
// Set resource dir // Set resource dir
void OMW::Engine::setResourceDir (const boost::filesystem::path& parResDir) void OMW::Engine::setResourceDir (const std::filesystem::path& parResDir)
{ {
mResDir = parResDir; mResDir = parResDir;
} }

@ -1,6 +1,8 @@
#ifndef ENGINE_H #ifndef ENGINE_H
#define ENGINE_H #define ENGINE_H
#include <filesystem>
#include <components/compiler/extensions.hpp> #include <components/compiler/extensions.hpp>
#include <components/files/collections.hpp> #include <components/files/collections.hpp>
#include <components/translation/translation.hpp> #include <components/translation/translation.hpp>
@ -135,7 +137,7 @@ namespace OMW
std::unique_ptr<ToUTF8::Utf8Encoder> mEncoder; std::unique_ptr<ToUTF8::Utf8Encoder> mEncoder;
Files::PathContainer mDataDirs; Files::PathContainer mDataDirs;
std::vector<std::string> mArchives; std::vector<std::string> mArchives;
boost::filesystem::path mResDir; std::filesystem::path mResDir;
osg::ref_ptr<osgViewer::Viewer> mViewer; osg::ref_ptr<osgViewer::Viewer> mViewer;
osg::ref_ptr<osgViewer::ScreenCaptureHandler> mScreenCaptureHandler; osg::ref_ptr<osgViewer::ScreenCaptureHandler> mScreenCaptureHandler;
osg::ref_ptr<SceneUtil::AsyncScreenCaptureOperation> mScreenCaptureOperation; osg::ref_ptr<SceneUtil::AsyncScreenCaptureOperation> mScreenCaptureOperation;
@ -203,7 +205,7 @@ namespace OMW
void addArchive(const std::string& archive); void addArchive(const std::string& archive);
/// Set resource dir /// Set resource dir
void setResourceDir(const boost::filesystem::path& parResDir); void setResourceDir(const std::filesystem::path& parResDir);
/// Set start cell name /// Set start cell name
void setCell(const std::string& cellName); void setCell(const std::string& cellName);

@ -1,14 +1,14 @@
#include "character.hpp" #include "character.hpp"
#include <cctype> #include <cctype>
#include <filesystem>
#include <sstream> #include <sstream>
#include <utility>
#include <boost/filesystem.hpp>
#include <components/esm3/esmreader.hpp>
#include <components/esm/defs.hpp> #include <components/esm/defs.hpp>
#include <components/esm3/esmreader.hpp>
#include <components/misc/utf8stream.hpp> #include <components/misc/utf8stream.hpp>
#include <components/misc/timeconvert.hpp>
#include <components/misc/strings/algorithm.hpp> #include <components/misc/strings/algorithm.hpp>
@ -27,11 +27,11 @@ std::string MWState::getFirstGameFile(const std::vector<std::string>& contentFil
return ""; return "";
} }
void MWState::Character::addSlot (const boost::filesystem::path& path, const std::string& game) void MWState::Character::addSlot (const std::filesystem::path& path, const std::string& game)
{ {
Slot slot; Slot slot;
slot.mPath = path; slot.mPath = path;
slot.mTimeStamp = boost::filesystem::last_write_time (path); slot.mTimeStamp = std::chrono::system_clock::to_time_t (Misc::clockCast<std::chrono::system_clock::time_point> (std::filesystem::last_write_time (path)));
ESM::ESMReader reader; ESM::ESMReader reader;
reader.open (slot.mPath.string()); reader.open (slot.mPath.string());
@ -71,7 +71,7 @@ void MWState::Character::addSlot (const ESM::SavedGame& profile)
// Append an index if necessary to ensure a unique file // Append an index if necessary to ensure a unique file
int i=0; int i=0;
while (boost::filesystem::exists(slot.mPath)) while (std::filesystem::exists(slot.mPath))
{ {
const std::string test = stream.str() + " - " + std::to_string(++i); const std::string test = stream.str() + " - " + std::to_string(++i);
slot.mPath = mPath / (test + ext); slot.mPath = mPath / (test + ext);
@ -83,19 +83,18 @@ void MWState::Character::addSlot (const ESM::SavedGame& profile)
mSlots.push_back (slot); mSlots.push_back (slot);
} }
MWState::Character::Character (const boost::filesystem::path& saves, const std::string& game) MWState::Character::Character (std::filesystem::path saves, const std::string& game)
: mPath (saves) : mPath (std::move(saves))
{ {
if (!boost::filesystem::is_directory (mPath)) if (!std::filesystem::is_directory (mPath))
{ {
boost::filesystem::create_directories (mPath); std::filesystem::create_directories (mPath);
} }
else else
{ {
for (boost::filesystem::directory_iterator iter (mPath); for (std::filesystem::directory_iterator iter (mPath); iter!=std::filesystem::directory_iterator(); ++iter)
iter!=boost::filesystem::directory_iterator(); ++iter)
{ {
boost::filesystem::path slotPath = *iter; std::filesystem::path slotPath = *iter;
try try
{ {
@ -110,15 +109,15 @@ MWState::Character::Character (const boost::filesystem::path& saves, const std::
void MWState::Character::cleanup() void MWState::Character::cleanup()
{ {
if (mSlots.size() == 0) if (mSlots.empty())
{ {
// All slots are gone, no need to keep the empty directory // All slots are gone, no need to keep the empty directory
if (boost::filesystem::is_directory (mPath)) if (std::filesystem::is_directory (mPath))
{ {
// Extra safety check to make sure the directory is empty (e.g. slots failed to parse header) // Extra safety check to make sure the directory is empty (e.g. slots failed to parse header)
boost::filesystem::directory_iterator it(mPath); std::filesystem::directory_iterator it(mPath);
if (it == boost::filesystem::directory_iterator()) if (it == std::filesystem::directory_iterator())
boost::filesystem::remove_all(mPath); std::filesystem::remove_all(mPath);
} }
} }
} }
@ -140,7 +139,7 @@ void MWState::Character::deleteSlot (const Slot *slot)
throw std::logic_error ("slot not found"); throw std::logic_error ("slot not found");
} }
boost::filesystem::remove(slot->mPath); std::filesystem::remove(slot->mPath);
mSlots.erase (mSlots.begin()+index); mSlots.erase (mSlots.begin()+index);
} }
@ -195,7 +194,7 @@ ESM::SavedGame MWState::Character::getSignature() const
return slot.mProfile; return slot.mProfile;
} }
const boost::filesystem::path& MWState::Character::getPath() const const std::filesystem::path& MWState::Character::getPath() const
{ {
return mPath; return mPath;
} }

@ -1,7 +1,7 @@
#ifndef GAME_STATE_CHARACTER_H #ifndef GAME_STATE_CHARACTER_H
#define GAME_STATE_CHARACTER_H #define GAME_STATE_CHARACTER_H
#include <boost/filesystem/path.hpp> #include <filesystem>
#include <components/esm3/savedgame.hpp> #include <components/esm3/savedgame.hpp>
@ -9,7 +9,7 @@ namespace MWState
{ {
struct Slot struct Slot
{ {
boost::filesystem::path mPath; std::filesystem::path mPath;
ESM::SavedGame mProfile; ESM::SavedGame mProfile;
std::time_t mTimeStamp; std::time_t mTimeStamp;
}; };
@ -26,16 +26,16 @@ namespace MWState
private: private:
boost::filesystem::path mPath; std::filesystem::path mPath;
std::vector<Slot> mSlots; std::vector<Slot> mSlots;
void addSlot (const boost::filesystem::path& path, const std::string& game); void addSlot (const std::filesystem::path& path, const std::string& game);
void addSlot (const ESM::SavedGame& profile); void addSlot (const ESM::SavedGame& profile);
public: public:
Character (const boost::filesystem::path& saves, const std::string& game); Character (std::filesystem::path saves, const std::string& game);
void cleanup(); void cleanup();
///< Delete the directory we used, if it is empty ///< Delete the directory we used, if it is empty
@ -60,7 +60,7 @@ namespace MWState
SlotIterator end() const; SlotIterator end() const;
const boost::filesystem::path& getPath() const; const std::filesystem::path& getPath() const;
ESM::SavedGame getSignature() const; ESM::SavedGame getSignature() const;
///< Return signature information for this character. ///< Return signature information for this character.

@ -2,27 +2,27 @@
#include <cctype> #include <cctype>
#include <sstream> #include <sstream>
#include <filesystem>
#include <boost/filesystem.hpp> #include <utility>
#include <components/misc/utf8stream.hpp> #include <components/misc/utf8stream.hpp>
MWState::CharacterManager::CharacterManager (const boost::filesystem::path& saves, MWState::CharacterManager::CharacterManager (std::filesystem::path saves,
const std::vector<std::string>& contentFiles) const std::vector<std::string>& contentFiles)
: mPath (saves), mCurrent (nullptr), mGame (getFirstGameFile(contentFiles)) : mPath (std::move(saves)), mCurrent (nullptr), mGame (getFirstGameFile(contentFiles))
{ {
if (!boost::filesystem::is_directory (mPath)) if (!std::filesystem::is_directory (mPath))
{ {
boost::filesystem::create_directories (mPath); std::filesystem::create_directories (mPath);
} }
else else
{ {
for (boost::filesystem::directory_iterator iter (mPath); for (std::filesystem::directory_iterator iter (mPath);
iter!=boost::filesystem::directory_iterator(); ++iter) iter!=std::filesystem::directory_iterator(); ++iter)
{ {
boost::filesystem::path characterDir = *iter; std::filesystem::path characterDir = *iter;
if (boost::filesystem::is_directory (characterDir)) if (std::filesystem::is_directory (characterDir))
{ {
Character character (characterDir, mGame); Character character (characterDir, mGame);
@ -69,11 +69,11 @@ MWState::Character* MWState::CharacterManager::createCharacter(const std::string
stream << '_'; stream << '_';
} }
boost::filesystem::path path = mPath / stream.str(); std::filesystem::path path = mPath / stream.str();
// Append an index if necessary to ensure a unique directory // Append an index if necessary to ensure a unique directory
int i=0; int i=0;
while (boost::filesystem::exists(path)) while (std::filesystem::exists(path))
{ {
std::ostringstream test; std::ostringstream test;
test << stream.str(); test << stream.str();

@ -1,7 +1,8 @@
#ifndef GAME_STATE_CHARACTERMANAGER_H #ifndef GAME_STATE_CHARACTERMANAGER_H
#define GAME_STATE_CHARACTERMANAGER_H #define GAME_STATE_CHARACTERMANAGER_H
#include <boost/filesystem/path.hpp> #include <filesystem>
#include <list>
#include "character.hpp" #include "character.hpp"
@ -9,7 +10,7 @@ namespace MWState
{ {
class CharacterManager class CharacterManager
{ {
boost::filesystem::path mPath; std::filesystem::path mPath;
// Uses std::list, so that mCurrent stays valid when characters are deleted // Uses std::list, so that mCurrent stays valid when characters are deleted
std::list<Character> mCharacters; std::list<Character> mCharacters;
@ -29,7 +30,7 @@ namespace MWState
public: public:
CharacterManager (const boost::filesystem::path& saves, const std::vector<std::string>& contentFiles); CharacterManager (std::filesystem::path saves, const std::vector<std::string>& contentFiles);
Character *getCurrentCharacter (); Character *getCurrentCharacter ();
///< @note May return null ///< @note May return null

@ -18,9 +18,6 @@
#include <osgDB/Registry> #include <osgDB/Registry>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/operations.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/journal.hpp" #include "../mwbase/journal.hpp"
@ -91,7 +88,7 @@ std::map<int, int> MWState::StateManager::buildContentFileIndexMap (const ESM::E
return map; return map;
} }
MWState::StateManager::StateManager (const boost::filesystem::path& saves, const std::vector<std::string>& contentFiles) MWState::StateManager::StateManager (const std::filesystem::path& saves, const std::vector<std::string>& contentFiles)
: mQuitRequest (false), mAskLoadRecent(false), mState (State_NoGame), mCharacterManager (saves, contentFiles), mTimePlayed (0) : mQuitRequest (false), mAskLoadRecent(false), mState (State_NoGame), mCharacterManager (saves, contentFiles), mTimePlayed (0)
{ {
@ -301,7 +298,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
throw std::runtime_error("Write operation failed (memory stream)"); throw std::runtime_error("Write operation failed (memory stream)");
// All good, write to file // All good, write to file
boost::filesystem::ofstream filestream (slot->mPath, std::ios::binary); std::ofstream filestream (slot->mPath, std::ios::binary);
filestream << stream.rdbuf(); filestream << stream.rdbuf();
if (filestream.fail()) if (filestream.fail())
@ -327,7 +324,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(error.str(), buttons); MWBase::Environment::get().getWindowManager()->interactiveMessageBox(error.str(), buttons);
// If no file was written, clean up the slot // If no file was written, clean up the slot
if (character && slot && !boost::filesystem::exists(slot->mPath)) if (character && slot && !std::filesystem::exists(slot->mPath))
{ {
character->deleteSlot(slot); character->deleteSlot(slot);
character->cleanup(); character->cleanup();
@ -373,7 +370,7 @@ void MWState::StateManager::loadGame(const std::string& filepath)
{ {
for (const auto& slot : character) for (const auto& slot : character)
{ {
if (slot.mPath == boost::filesystem::path(filepath)) if (slot.mPath == std::filesystem::path(filepath))
{ {
loadGame(&character, slot.mPath.string()); loadGame(&character, slot.mPath.string());
return; return;

@ -2,11 +2,10 @@
#define GAME_STATE_STATEMANAGER_H #define GAME_STATE_STATEMANAGER_H
#include <map> #include <map>
#include <filesystem>
#include "../mwbase/statemanager.hpp" #include "../mwbase/statemanager.hpp"
#include <boost/filesystem/path.hpp>
#include "charactermanager.hpp" #include "charactermanager.hpp"
namespace MWState namespace MWState
@ -31,7 +30,7 @@ namespace MWState
public: public:
StateManager (const boost::filesystem::path& saves, const std::vector<std::string>& contentFiles); StateManager (const std::filesystem::path& saves, const std::vector<std::string>& contentFiles);
void requestQuit() override; void requestQuit() override;

@ -1,7 +1,7 @@
#ifndef CONTENTLOADER_HPP #ifndef CONTENTLOADER_HPP
#define CONTENTLOADER_HPP #define CONTENTLOADER_HPP
#include <boost/filesystem/path.hpp> #include <filesystem>
namespace Loading namespace Loading
{ {
@ -15,7 +15,7 @@ struct ContentLoader
{ {
virtual ~ContentLoader() = default; virtual ~ContentLoader() = default;
virtual void load(const boost::filesystem::path& filepath, int& index, Loading::Listener* listener) = 0; virtual void load(const std::filesystem::path& filepath, int& index, Loading::Listener* listener) = 0;
}; };
} /* namespace MWWorld */ } /* namespace MWWorld */

@ -16,7 +16,7 @@ EsmLoader::EsmLoader(MWWorld::ESMStore& store, ESM::ReadersCache& readers, ToUTF
{ {
} }
void EsmLoader::load(const boost::filesystem::path& filepath, int& index, Loading::Listener* listener) void EsmLoader::load(const std::filesystem::path& filepath, int& index, Loading::Listener* listener)
{ {
const ESM::ReadersCache::BusyItem reader = mReaders.get(static_cast<std::size_t>(index)); const ESM::ReadersCache::BusyItem reader = mReaders.get(static_cast<std::size_t>(index));

@ -27,7 +27,7 @@ struct EsmLoader : public ContentLoader
std::optional<int> getMasterFileFormat() const { return mMasterFileFormat; } std::optional<int> getMasterFileFormat() const { return mMasterFileFormat; }
void load(const boost::filesystem::path& filepath, int& index, Loading::Listener* listener) override; void load(const std::filesystem::path& filepath, int& index, Loading::Listener* listener) override;
private: private:
ESM::ReadersCache& mReaders; ESM::ReadersCache& mReaders;

@ -102,7 +102,7 @@ namespace MWWorld
mLoaders.emplace(std::move(extension), &loader); mLoaders.emplace(std::move(extension), &loader);
} }
void load(const boost::filesystem::path& filepath, int& index, Loading::Listener* listener) override void load(const std::filesystem::path& filepath, int& index, Loading::Listener* listener) override
{ {
const auto it = mLoaders.find(Misc::StringUtils::lowerCase(filepath.extension().string())); const auto it = mLoaders.find(Misc::StringUtils::lowerCase(filepath.extension().string()));
if (it != mLoaders.end()) if (it != mLoaders.end())
@ -129,7 +129,7 @@ namespace MWWorld
{ {
ESMStore& mStore; ESMStore& mStore;
OMWScriptsLoader(ESMStore& store) : mStore(store) {} OMWScriptsLoader(ESMStore& store) : mStore(store) {}
void load(const boost::filesystem::path& filepath, int& /*index*/, Loading::Listener* /*listener*/) override void load(const std::filesystem::path& filepath, int& /*index*/, Loading::Listener* /*listener*/) override
{ {
mStore.addOMWScripts(filepath.string()); mStore.addOMWScripts(filepath.string());
} }
@ -2963,7 +2963,7 @@ namespace MWWorld
int idx = 0; int idx = 0;
for (const std::string &file : content) for (const std::string &file : content)
{ {
boost::filesystem::path filename(file); std::filesystem::path filename(file);
const Files::MultiDirCollection& col = fileCollections.getCollection(filename.extension().string()); const Files::MultiDirCollection& col = fileCollections.getCollection(filename.extension().string());
if (col.doesExist(file)) if (col.doesExist(file))
{ {

@ -97,7 +97,7 @@ struct ContentFileTest : public ::testing::Test
protected: protected:
Files::ConfigurationManager mConfigurationManager; Files::ConfigurationManager mConfigurationManager;
MWWorld::ESMStore mEsmStore; MWWorld::ESMStore mEsmStore;
std::vector<boost::filesystem::path> mContentFiles; std::vector<std::filesystem::path> mContentFiles;
}; };
/// Print results of the dialogue merging process, i.e. the resulting linked list. /// Print results of the dialogue merging process, i.e. the resulting linked list.

@ -54,8 +54,8 @@ Wizard::MainWizard::MainWizard(QWidget *parent) :
<p>Please make sure you have the right permissions \ <p>Please make sure you have the right permissions \
and try again.</p></body></html>"); and try again.</p></body></html>");
boost::filesystem::create_directories(mCfgMgr.getUserConfigPath()); std::filesystem::create_directories(mCfgMgr.getUserConfigPath());
boost::filesystem::create_directories(mCfgMgr.getUserDataPath()); std::filesystem::create_directories(mCfgMgr.getUserDataPath());
setupLog(); setupLog();
setupGameSettings(); setupGameSettings();
@ -63,10 +63,10 @@ Wizard::MainWizard::MainWizard(QWidget *parent) :
setupInstallations(); setupInstallations();
setupPages(); setupPages();
const boost::filesystem::path& installationPath = mCfgMgr.getInstallPath(); const std::filesystem::path& installationPath = mCfgMgr.getInstallPath();
if (!installationPath.empty()) if (!installationPath.empty())
{ {
const boost::filesystem::path& dataPath = installationPath / "Data Files"; const std::filesystem::path& dataPath = installationPath / "Data Files";
addInstallation(toQString(dataPath)); addInstallation(toQString(dataPath));
} }
} }
@ -469,7 +469,7 @@ bool Wizard::MainWizard::findFiles(const QString &name, const QString &path)
&& dir.entryList().contains(name + QLatin1String(".bsa"), Qt::CaseInsensitive)); && dir.entryList().contains(name + QLatin1String(".bsa"), Qt::CaseInsensitive));
} }
QString Wizard::MainWizard::toQString(const boost::filesystem::path& path) QString Wizard::MainWizard::toQString(const std::filesystem::path& path)
{ {
return QString::fromUtf8(path.string().c_str()); return QString::fromUtf8(path.string().c_str());
} }

@ -58,8 +58,8 @@ namespace Wizard
void addLogText(const QString &text); void addLogText(const QString &text);
private: private:
/// convert boost::filesystem::path to QString /// convert std::filesystem::path to QString
QString toQString(const boost::filesystem::path& path); QString toQString(const std::filesystem::path& path);
void setupLog(); void setupLog();
void setupGameSettings(); void setupGameSettings();

@ -411,7 +411,6 @@ target_link_libraries(components
${OPENTHREADS_LIBRARIES} ${OPENTHREADS_LIBRARIES}
${Boost_SYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_IOSTREAMS_LIBRARY} ${Boost_IOSTREAMS_LIBRARY}

@ -68,8 +68,8 @@ void Config::GameSettings::validatePaths()
std::string Config::GameSettings::getGlobalDataDir() const std::string Config::GameSettings::getGlobalDataDir() const
{ {
// global data dir may not exists if OpenMW is not installed (ie if run from build directory) // global data dir may not exists if OpenMW is not installed (ie if run from build directory)
if (boost::filesystem::exists(mCfgMgr.getGlobalDataPath())) if (std::filesystem::exists(mCfgMgr.getGlobalDataPath()))
return boost::filesystem::canonical(mCfgMgr.getGlobalDataPath()).string(); return std::filesystem::canonical(mCfgMgr.getGlobalDataPath()).string();
return {}; return {};
} }
@ -173,7 +173,7 @@ bool Config::GameSettings::writeFile(QTextStream &stream)
while (i.hasPrevious()) { while (i.hasPrevious()) {
i.previous(); i.previous();
// path lines (e.g. 'data=...') need quotes and ampersands escaping to match how boost::filesystem::path uses boost::io::quoted // path lines (e.g. 'data=...') need quotes and ampersands escaping to match how std::filesystem::path uses boost::io::quoted
if (i.key() == QLatin1String("data") if (i.key() == QLatin1String("data")
|| i.key() == QLatin1String("data-local") || i.key() == QLatin1String("data-local")
|| i.key() == QLatin1String("resources") || i.key() == QLatin1String("resources")

@ -1,17 +1,17 @@
#ifndef GAMESETTINGS_HPP #ifndef GAMESETTINGS_HPP
#define GAMESETTINGS_HPP #define GAMESETTINGS_HPP
#include <filesystem>
#include <QTextStream> #include <QTextStream>
#include <QStringList> #include <QStringList>
#include <QString> #include <QString>
#include <QFile> #include <QFile>
#include <QMultiMap> #include <QMultiMap>
#include <boost/filesystem/path.hpp>
namespace Files namespace Files
{ {
typedef std::vector<boost::filesystem::path> PathContainer; typedef std::vector<std::filesystem::path> PathContainer;
struct ConfigurationManager; struct ConfigurationManager;
} }

@ -2,9 +2,9 @@
#include <chrono> #include <chrono>
#include <memory> #include <memory>
#include <functional>
#include <fstream> #include <fstream>
#include <filesystem>
#include <boost/iostreams/stream.hpp>
#include <components/crashcatcher/crashcatcher.hpp> #include <components/crashcatcher/crashcatcher.hpp>
#include <components/files/configurationmanager.hpp> #include <components/files/configurationmanager.hpp>

@ -1,8 +1,8 @@
#ifndef DEBUG_DEBUGGING_H #ifndef DEBUG_DEBUGGING_H
#define DEBUG_DEBUGGING_H #define DEBUG_DEBUGGING_H
#include <boost/filesystem/fstream.hpp> #include <filesystem>
#include <boost/iostreams/stream.hpp> #include <functional>
#include <components/misc/guarded.hpp> #include <components/misc/guarded.hpp>

@ -7,7 +7,7 @@
#include <cstring> #include <cstring>
#include <pwd.h> #include <pwd.h>
#include <unistd.h> #include <unistd.h>
#include <boost/filesystem/fstream.hpp> #include <filesystem>
static const char *g_path_global; //< Path to global directory root, e.g. /data/data/com.libopenmw.openmw static const char *g_path_global; //< Path to global directory root, e.g. /data/data/com.libopenmw.openmw
static const char *g_path_user; //< Path to user root, e.g. /sdcard/Android/data/com.libopenmw.openmw static const char *g_path_user; //< Path to user root, e.g. /sdcard/Android/data/com.libopenmw.openmw
@ -29,47 +29,47 @@ AndroidPath::AndroidPath(const std::string& application_name)
} }
// /sdcard/Android/data/com.libopenmw.openmw/config // /sdcard/Android/data/com.libopenmw.openmw/config
boost::filesystem::path AndroidPath::getUserConfigPath() const std::filesystem::path AndroidPath::getUserConfigPath() const
{ {
return boost::filesystem::path(g_path_user) / "config"; return std::filesystem::path(g_path_user) / "config";
} }
// /sdcard/Android/data/com.libopenmw.openmw/ // /sdcard/Android/data/com.libopenmw.openmw/
// (so that saves are placed at /sdcard/Android/data/com.libopenmw.openmw/saves) // (so that saves are placed at /sdcard/Android/data/com.libopenmw.openmw/saves)
boost::filesystem::path AndroidPath::getUserDataPath() const std::filesystem::path AndroidPath::getUserDataPath() const
{ {
return boost::filesystem::path(g_path_user); return std::filesystem::path(g_path_user);
} }
// /data/data/com.libopenmw.openmw/cache // /data/data/com.libopenmw.openmw/cache
// (supposed to be "official" android cache location) // (supposed to be "official" android cache location)
boost::filesystem::path AndroidPath::getCachePath() const std::filesystem::path AndroidPath::getCachePath() const
{ {
return boost::filesystem::path(g_path_global) / "cache"; return std::filesystem::path(g_path_global) / "cache";
} }
// /data/data/com.libopenmw.openmw/files/config // /data/data/com.libopenmw.openmw/files/config
// (note the addition of "files") // (note the addition of "files")
boost::filesystem::path AndroidPath::getGlobalConfigPath() const std::filesystem::path AndroidPath::getGlobalConfigPath() const
{ {
return boost::filesystem::path(g_path_global) / "files" / "config"; return std::filesystem::path(g_path_global) / "files" / "config";
} }
boost::filesystem::path AndroidPath::getLocalPath() const std::filesystem::path AndroidPath::getLocalPath() const
{ {
return boost::filesystem::path("./"); return std::filesystem::path("./");
} }
// /sdcard/Android/data/com.libopenmw.openmw // /sdcard/Android/data/com.libopenmw.openmw
// (so that the data is at /sdcard/Android/data/com.libopenmw.openmw/data) // (so that the data is at /sdcard/Android/data/com.libopenmw.openmw/data)
boost::filesystem::path AndroidPath::getGlobalDataPath() const std::filesystem::path AndroidPath::getGlobalDataPath() const
{ {
return boost::filesystem::path(g_path_user); return std::filesystem::path(g_path_user);
} }
boost::filesystem::path AndroidPath::getInstallPath() const std::filesystem::path AndroidPath::getInstallPath() const
{ {
return boost::filesystem::path(); return std::filesystem::path();
} }

@ -3,7 +3,7 @@
#if defined(__ANDROID__) #if defined(__ANDROID__)
#include <boost/filesystem.hpp> #include <filesystem>
/** /**
* \namespace Files * \namespace Files
*/ */
@ -20,32 +20,32 @@ struct AndroidPath
/** /**
* \brief Return path to the user directory. * \brief Return path to the user directory.
*/ */
boost::filesystem::path getUserConfigPath() const; std::filesystem::path getUserConfigPath() const;
boost::filesystem::path getUserDataPath() const; std::filesystem::path getUserDataPath() const;
/** /**
* \brief Return path to the global (system) directory where config files can be placed. * \brief Return path to the global (system) directory where config files can be placed.
*/ */
boost::filesystem::path getGlobalConfigPath() const; std::filesystem::path getGlobalConfigPath() const;
/** /**
* \brief Return path to the runtime configuration directory which is the * \brief Return path to the runtime configuration directory which is the
* place where an application was started. * place where an application was started.
*/ */
boost::filesystem::path getLocalPath() const; std::filesystem::path getLocalPath() const;
/** /**
* \brief Return path to the global (system) directory where game files can be placed. * \brief Return path to the global (system) directory where game files can be placed.
*/ */
boost::filesystem::path getGlobalDataPath() const; std::filesystem::path getGlobalDataPath() const;
/** /**
* \brief * \brief
*/ */
boost::filesystem::path getCachePath() const; std::filesystem::path getCachePath() const;
boost::filesystem::path getInstallPath() const; std::filesystem::path getInstallPath() const;
}; };
} /* namespace Files */ } /* namespace Files */

@ -34,15 +34,15 @@ namespace Files
return iter->second; return iter->second;
} }
boost::filesystem::path Collections::getPath(const std::string& file) const std::filesystem::path Collections::getPath(const std::string& file) const
{ {
for (Files::PathContainer::const_iterator iter = mDirectories.begin(); for (Files::PathContainer::const_iterator iter = mDirectories.begin();
iter != mDirectories.end(); ++iter) iter != mDirectories.end(); ++iter)
{ {
for (boost::filesystem::directory_iterator iter2 (*iter); for (std::filesystem::directory_iterator iter2 (*iter);
iter2!=boost::filesystem::directory_iterator(); ++iter2) iter2!=std::filesystem::directory_iterator(); ++iter2)
{ {
boost::filesystem::path path = *iter2; std::filesystem::path path = *iter2;
if (mFoldCase) if (mFoldCase)
{ {
@ -62,10 +62,10 @@ namespace Files
for (Files::PathContainer::const_iterator iter = mDirectories.begin(); for (Files::PathContainer::const_iterator iter = mDirectories.begin();
iter != mDirectories.end(); ++iter) iter != mDirectories.end(); ++iter)
{ {
for (boost::filesystem::directory_iterator iter2 (*iter); for (std::filesystem::directory_iterator iter2 (*iter);
iter2!=boost::filesystem::directory_iterator(); ++iter2) iter2!=std::filesystem::directory_iterator(); ++iter2)
{ {
boost::filesystem::path path = *iter2; std::filesystem::path path = *iter2;
if (mFoldCase) if (mFoldCase)
{ {

@ -1,7 +1,7 @@
#ifndef COMPONENTS_FILES_COLLECTION_HPP #ifndef COMPONENTS_FILES_COLLECTION_HPP
#define COMPONENTS_FILES_COLLECTION_HPP #define COMPONENTS_FILES_COLLECTION_HPP
#include <boost/filesystem.hpp> #include <filesystem>
#include "multidircollection.hpp" #include "multidircollection.hpp"
@ -19,7 +19,7 @@ namespace Files
/// leading dot and must be all lower-case. /// leading dot and must be all lower-case.
const MultiDirCollection& getCollection(const std::string& extension) const; const MultiDirCollection& getCollection(const std::string& extension) const;
boost::filesystem::path getPath(const std::string& file) const; std::filesystem::path getPath(const std::string& file) const;
///< Return full path (including filename) of \a file. ///< Return full path (including filename) of \a file.
/// ///
/// If the file does not exist in any of the collection's /// If the file does not exist in any of the collection's

@ -1,10 +1,11 @@
#include "configurationmanager.hpp" #include "configurationmanager.hpp"
#include <fstream>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/files/configfileparser.hpp> #include <components/files/configfileparser.hpp>
#include <components/fallback/validate.hpp> #include <components/fallback/validate.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/program_options/variables_map.hpp> #include <boost/program_options/variables_map.hpp>
#include <boost/program_options/options_description.hpp> #include <boost/program_options/options_description.hpp>
@ -86,18 +87,18 @@ void ConfigurationManager::readConfiguration(bpo::variables_map& variables,
return; return;
} }
std::stack<boost::filesystem::path> extraConfigDirs; std::stack<std::filesystem::path> extraConfigDirs;
addExtraConfigDirs(extraConfigDirs, variables); addExtraConfigDirs(extraConfigDirs, variables);
if (!hasReplaceConfig(variables)) if (!hasReplaceConfig(variables))
addExtraConfigDirs(extraConfigDirs, *config); addExtraConfigDirs(extraConfigDirs, *config);
std::vector<bpo::variables_map> parsedConfigs{*std::move(config)}; std::vector<bpo::variables_map> parsedConfigs{*std::move(config)};
std::set<boost::filesystem::path> alreadyParsedPaths; // needed to prevent infinite loop in case of a circular link std::set<std::filesystem::path> alreadyParsedPaths; // needed to prevent infinite loop in case of a circular link
alreadyParsedPaths.insert(boost::filesystem::path(mActiveConfigPaths.front())); alreadyParsedPaths.insert(std::filesystem::path(mActiveConfigPaths.front()));
while (!extraConfigDirs.empty()) while (!extraConfigDirs.empty())
{ {
boost::filesystem::path path = extraConfigDirs.top(); std::filesystem::path path = extraConfigDirs.top();
extraConfigDirs.pop(); extraConfigDirs.pop();
if (alreadyParsedPaths.count(path) > 0) if (alreadyParsedPaths.count(path) > 0)
{ {
@ -145,11 +146,11 @@ void ConfigurationManager::readConfiguration(bpo::variables_map& variables,
} }
mScreenshotPath = mUserDataPath / "screenshots"; mScreenshotPath = mUserDataPath / "screenshots";
boost::filesystem::create_directories(getUserConfigPath()); std::filesystem::create_directories(getUserConfigPath());
boost::filesystem::create_directories(mScreenshotPath); std::filesystem::create_directories(mScreenshotPath);
// probably not necessary but validate the creation of the screenshots directory and fallback to the original behavior if it fails // probably not necessary but validate the creation of the screenshots directory and fallback to the original behavior if it fails
if (!boost::filesystem::is_directory(mScreenshotPath)) if (!std::filesystem::is_directory(mScreenshotPath))
mScreenshotPath = mUserDataPath; mScreenshotPath = mUserDataPath;
if (!quiet) if (!quiet)
@ -162,7 +163,7 @@ void ConfigurationManager::readConfiguration(bpo::variables_map& variables,
mSilent = silent; mSilent = silent;
} }
void ConfigurationManager::addExtraConfigDirs(std::stack<boost::filesystem::path>& dirs, void ConfigurationManager::addExtraConfigDirs(std::stack<std::filesystem::path>& dirs,
const bpo::variables_map& variables) const const bpo::variables_map& variables) const
{ {
auto configIt = variables.find("config"); auto configIt = variables.find("config");
@ -267,7 +268,7 @@ void mergeComposingVariables(bpo::variables_map& first, bpo::variables_map& seco
} }
} }
void ConfigurationManager::processPath(boost::filesystem::path& path, const boost::filesystem::path& basePath) const void ConfigurationManager::processPath(std::filesystem::path& path, const std::filesystem::path& basePath) const
{ {
std::string str = path.string(); std::string str = path.string();
@ -284,7 +285,7 @@ void ConfigurationManager::processPath(boost::filesystem::path& path, const boos
auto tokenIt = mTokensMapping.find(str.substr(0, pos + 1)); auto tokenIt = mTokensMapping.find(str.substr(0, pos + 1));
if (tokenIt != mTokensMapping.end()) if (tokenIt != mTokensMapping.end())
{ {
boost::filesystem::path tempPath(((mFixedPath).*(tokenIt->second))()); std::filesystem::path tempPath(((mFixedPath).*(tokenIt->second))());
if (pos < str.length() - 1) if (pos < str.length() - 1)
{ {
// There is something after the token, so we should // There is something after the token, so we should
@ -303,13 +304,13 @@ void ConfigurationManager::processPath(boost::filesystem::path& path, const boos
} }
} }
void ConfigurationManager::processPaths(Files::PathContainer& dataDirs, const boost::filesystem::path& basePath) const void ConfigurationManager::processPaths(Files::PathContainer& dataDirs, const std::filesystem::path& basePath) const
{ {
for (auto& path : dataDirs) for (auto& path : dataDirs)
processPath(path, basePath); processPath(path, basePath);
} }
void ConfigurationManager::processPaths(boost::program_options::variables_map& variables, const boost::filesystem::path& basePath) const void ConfigurationManager::processPaths(boost::program_options::variables_map& variables, const std::filesystem::path& basePath) const
{ {
for (auto& [name, var] : variables) for (auto& [name, var] : variables)
{ {
@ -323,7 +324,7 @@ void ConfigurationManager::processPaths(boost::program_options::variables_map& v
} }
else if (var.value().type() == typeid(MaybeQuotedPath)) else if (var.value().type() == typeid(MaybeQuotedPath))
{ {
boost::filesystem::path& path = boost::any_cast<Files::MaybeQuotedPath&>(var.value()); std::filesystem::path& path = boost::any_cast<Files::MaybeQuotedPath&>(var.value());
processPath(path, basePath); processPath(path, basePath);
} }
} }
@ -332,9 +333,9 @@ void ConfigurationManager::processPaths(boost::program_options::variables_map& v
void ConfigurationManager::filterOutNonExistingPaths(Files::PathContainer& dataDirs) const void ConfigurationManager::filterOutNonExistingPaths(Files::PathContainer& dataDirs) const
{ {
dataDirs.erase(std::remove_if(dataDirs.begin(), dataDirs.end(), dataDirs.erase(std::remove_if(dataDirs.begin(), dataDirs.end(),
[this](const boost::filesystem::path& p) [this](const std::filesystem::path& p)
{ {
bool exists = boost::filesystem::is_directory(p); bool exists = std::filesystem::is_directory(p);
if (!exists && !mSilent) if (!exists && !mSilent)
Log(Debug::Warning) << "No such dir: " << p; Log(Debug::Warning) << "No such dir: " << p;
return !exists; return !exists;
@ -343,16 +344,16 @@ void ConfigurationManager::filterOutNonExistingPaths(Files::PathContainer& dataD
} }
std::optional<bpo::variables_map> ConfigurationManager::loadConfig( std::optional<bpo::variables_map> ConfigurationManager::loadConfig(
const boost::filesystem::path& path, const bpo::options_description& description) const const std::filesystem::path& path, const bpo::options_description& description) const
{ {
boost::filesystem::path cfgFile(path); std::filesystem::path cfgFile(path);
cfgFile /= std::string(openmwCfgFile); cfgFile /= std::string(openmwCfgFile);
if (boost::filesystem::is_regular_file(cfgFile)) if (std::filesystem::is_regular_file(cfgFile))
{ {
if (!mSilent) if (!mSilent)
Log(Debug::Info) << "Loading config file: " << cfgFile.string(); Log(Debug::Info) << "Loading config file: " << cfgFile.string();
boost::filesystem::ifstream configFileStream(cfgFile); std::ifstream configFileStream(cfgFile);
if (configFileStream.is_open()) if (configFileStream.is_open())
{ {
@ -367,12 +368,12 @@ std::optional<bpo::variables_map> ConfigurationManager::loadConfig(
return std::nullopt; return std::nullopt;
} }
const boost::filesystem::path& ConfigurationManager::getGlobalPath() const const std::filesystem::path& ConfigurationManager::getGlobalPath() const
{ {
return mFixedPath.getGlobalConfigPath(); return mFixedPath.getGlobalConfigPath();
} }
const boost::filesystem::path& ConfigurationManager::getUserConfigPath() const const std::filesystem::path& ConfigurationManager::getUserConfigPath() const
{ {
if (mActiveConfigPaths.empty()) if (mActiveConfigPaths.empty())
return mFixedPath.getUserConfigPath(); return mFixedPath.getUserConfigPath();
@ -380,32 +381,32 @@ const boost::filesystem::path& ConfigurationManager::getUserConfigPath() const
return mActiveConfigPaths.back(); return mActiveConfigPaths.back();
} }
const boost::filesystem::path& ConfigurationManager::getUserDataPath() const const std::filesystem::path& ConfigurationManager::getUserDataPath() const
{ {
return mUserDataPath; return mUserDataPath;
} }
const boost::filesystem::path& ConfigurationManager::getLocalPath() const const std::filesystem::path& ConfigurationManager::getLocalPath() const
{ {
return mFixedPath.getLocalPath(); return mFixedPath.getLocalPath();
} }
const boost::filesystem::path& ConfigurationManager::getGlobalDataPath() const const std::filesystem::path& ConfigurationManager::getGlobalDataPath() const
{ {
return mFixedPath.getGlobalDataPath(); return mFixedPath.getGlobalDataPath();
} }
const boost::filesystem::path& ConfigurationManager::getCachePath() const const std::filesystem::path& ConfigurationManager::getCachePath() const
{ {
return mFixedPath.getCachePath(); return mFixedPath.getCachePath();
} }
const boost::filesystem::path& ConfigurationManager::getInstallPath() const const std::filesystem::path& ConfigurationManager::getInstallPath() const
{ {
return mFixedPath.getInstallPath(); return mFixedPath.getInstallPath();
} }
const boost::filesystem::path& ConfigurationManager::getScreenshotPath() const const std::filesystem::path& ConfigurationManager::getScreenshotPath() const
{ {
return mScreenshotPath; return mScreenshotPath;
} }
@ -426,12 +427,12 @@ void parseConfig(std::istream& stream, bpo::variables_map& variables, const bpo:
std::istream& operator>> (std::istream& istream, MaybeQuotedPath& MaybeQuotedPath) std::istream& operator>> (std::istream& istream, MaybeQuotedPath& MaybeQuotedPath)
{ {
// If the stream starts with a double quote, read from stream using boost::filesystem::path rules, then discard anything remaining. // If the stream starts with a double quote, read from stream using std::filesystem::path rules, then discard anything remaining.
// This prevents boost::program_options getting upset that we've not consumed the whole stream. // This prevents boost::program_options getting upset that we've not consumed the whole stream.
// If it doesn't start with a double quote, read the whole thing verbatim // If it doesn't start with a double quote, read the whole thing verbatim
if (istream.peek() == '"') if (istream.peek() == '"')
{ {
istream >> static_cast<boost::filesystem::path&>(MaybeQuotedPath); istream >> static_cast<std::filesystem::path&>(MaybeQuotedPath);
if (istream && !istream.eof() && istream.peek() != EOF) if (istream && !istream.eof() && istream.peek() != EOF)
{ {
std::string remainder{std::istreambuf_iterator(istream), {}}; std::string remainder{std::istreambuf_iterator(istream), {}};
@ -441,7 +442,7 @@ std::istream& operator>> (std::istream& istream, MaybeQuotedPath& MaybeQuotedPat
else else
{ {
std::string intermediate{std::istreambuf_iterator(istream), {}}; std::string intermediate{std::istreambuf_iterator(istream), {}};
static_cast<boost::filesystem::path&>(MaybeQuotedPath) = intermediate; static_cast<std::filesystem::path&>(MaybeQuotedPath) = intermediate;
} }
return istream; return istream;
} }

@ -34,49 +34,49 @@ struct ConfigurationManager
void filterOutNonExistingPaths(Files::PathContainer& dataDirs) const; void filterOutNonExistingPaths(Files::PathContainer& dataDirs) const;
// Replaces tokens (`?local?`, `?global?`, etc.) in paths. Adds `basePath` prefix for relative paths. // Replaces tokens (`?local?`, `?global?`, etc.) in paths. Adds `basePath` prefix for relative paths.
void processPath(boost::filesystem::path& path, const boost::filesystem::path& basePath) const; void processPath(std::filesystem::path& path, const std::filesystem::path& basePath) const;
void processPaths(Files::PathContainer& dataDirs, const boost::filesystem::path& basePath) const; void processPaths(Files::PathContainer& dataDirs, const std::filesystem::path& basePath) const;
void processPaths(boost::program_options::variables_map& variables, const boost::filesystem::path& basePath) const; void processPaths(boost::program_options::variables_map& variables, const std::filesystem::path& basePath) const;
/**< Fixed paths */ /**< Fixed paths */
const boost::filesystem::path& getGlobalPath() const; const std::filesystem::path& getGlobalPath() const;
const boost::filesystem::path& getLocalPath() const; const std::filesystem::path& getLocalPath() const;
const boost::filesystem::path& getGlobalDataPath() const; const std::filesystem::path& getGlobalDataPath() const;
const boost::filesystem::path& getUserConfigPath() const; const std::filesystem::path& getUserConfigPath() const;
const boost::filesystem::path& getUserDataPath() const; const std::filesystem::path& getUserDataPath() const;
const boost::filesystem::path& getLocalDataPath() const; const std::filesystem::path& getLocalDataPath() const;
const boost::filesystem::path& getInstallPath() const; const std::filesystem::path& getInstallPath() const;
const std::vector<boost::filesystem::path>& getActiveConfigPaths() const { return mActiveConfigPaths; } const std::vector<std::filesystem::path>& getActiveConfigPaths() const { return mActiveConfigPaths; }
const boost::filesystem::path& getCachePath() const; const std::filesystem::path& getCachePath() const;
const boost::filesystem::path& getLogPath() const { return getUserConfigPath(); } const std::filesystem::path& getLogPath() const { return getUserConfigPath(); }
const boost::filesystem::path& getScreenshotPath() const; const std::filesystem::path& getScreenshotPath() const;
static void addCommonOptions(boost::program_options::options_description& description); static void addCommonOptions(boost::program_options::options_description& description);
private: private:
typedef Files::FixedPath<> FixedPathType; typedef Files::FixedPath<> FixedPathType;
typedef const boost::filesystem::path& (FixedPathType::*path_type_f)() const; typedef const std::filesystem::path& (FixedPathType::*path_type_f)() const;
typedef std::map<std::string, path_type_f> TokensMappingContainer; typedef std::map<std::string, path_type_f> TokensMappingContainer;
std::optional<boost::program_options::variables_map> loadConfig( std::optional<boost::program_options::variables_map> loadConfig(
const boost::filesystem::path& path, const std::filesystem::path& path,
const boost::program_options::options_description& description) const; const boost::program_options::options_description& description) const;
void addExtraConfigDirs(std::stack<boost::filesystem::path>& dirs, void addExtraConfigDirs(std::stack<std::filesystem::path>& dirs,
const boost::program_options::variables_map& variables) const; const boost::program_options::variables_map& variables) const;
void setupTokensMapping(); void setupTokensMapping();
std::vector<boost::filesystem::path> mActiveConfigPaths; std::vector<std::filesystem::path> mActiveConfigPaths;
FixedPathType mFixedPath; FixedPathType mFixedPath;
boost::filesystem::path mUserDataPath; std::filesystem::path mUserDataPath;
boost::filesystem::path mScreenshotPath; std::filesystem::path mScreenshotPath;
TokensMappingContainer mTokensMapping; TokensMappingContainer mTokensMapping;
@ -95,7 +95,7 @@ void parseArgs(int argc, const char* const argv[], boost::program_options::varia
void parseConfig(std::istream& stream, boost::program_options::variables_map& variables, void parseConfig(std::istream& stream, boost::program_options::variables_map& variables,
const boost::program_options::options_description& description); const boost::program_options::options_description& description);
class MaybeQuotedPath : public boost::filesystem::path class MaybeQuotedPath : public std::filesystem::path
{ {
}; };

@ -2,7 +2,7 @@
#define COMPONENTS_FILES_FIXEDPATH_HPP #define COMPONENTS_FILES_FIXEDPATH_HPP
#include <string> #include <string>
#include <boost/filesystem.hpp> #include <filesystem>
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) #if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
#ifndef ANDROID #ifndef ANDROID
@ -65,12 +65,12 @@ struct FixedPath
/** /**
* \brief Return path pointing to the user local configuration directory. * \brief Return path pointing to the user local configuration directory.
*/ */
const boost::filesystem::path& getUserConfigPath() const const std::filesystem::path& getUserConfigPath() const
{ {
return mUserConfigPath; return mUserConfigPath;
} }
const boost::filesystem::path& getUserDataPath() const const std::filesystem::path& getUserDataPath() const
{ {
return mUserDataPath; return mUserDataPath;
} }
@ -78,7 +78,7 @@ struct FixedPath
/** /**
* \brief Return path pointing to the global (system) configuration directory. * \brief Return path pointing to the global (system) configuration directory.
*/ */
const boost::filesystem::path& getGlobalConfigPath() const const std::filesystem::path& getGlobalConfigPath() const
{ {
return mGlobalConfigPath; return mGlobalConfigPath;
} }
@ -86,23 +86,23 @@ struct FixedPath
/** /**
* \brief Return path pointing to the directory where application was started. * \brief Return path pointing to the directory where application was started.
*/ */
const boost::filesystem::path& getLocalPath() const const std::filesystem::path& getLocalPath() const
{ {
return mLocalPath; return mLocalPath;
} }
const boost::filesystem::path& getInstallPath() const const std::filesystem::path& getInstallPath() const
{ {
return mInstallPath; return mInstallPath;
} }
const boost::filesystem::path& getGlobalDataPath() const const std::filesystem::path& getGlobalDataPath() const
{ {
return mGlobalDataPath; return mGlobalDataPath;
} }
const boost::filesystem::path& getCachePath() const const std::filesystem::path& getCachePath() const
{ {
return mCachePath; return mCachePath;
} }
@ -110,16 +110,16 @@ struct FixedPath
private: private:
PathType mPath; PathType mPath;
boost::filesystem::path mUserConfigPath; /**< User path */ std::filesystem::path mUserConfigPath; /**< User path */
boost::filesystem::path mUserDataPath; std::filesystem::path mUserDataPath;
boost::filesystem::path mGlobalConfigPath; /**< Global path */ std::filesystem::path mGlobalConfigPath; /**< Global path */
boost::filesystem::path mLocalPath; /**< It is the same directory where application was run */ std::filesystem::path mLocalPath; /**< It is the same directory where application was run */
boost::filesystem::path mGlobalDataPath; /**< Global application data path */ std::filesystem::path mGlobalDataPath; /**< Global application data path */
boost::filesystem::path mCachePath; std::filesystem::path mCachePath;
boost::filesystem::path mInstallPath; std::filesystem::path mInstallPath;
}; };

@ -4,14 +4,15 @@
#include <pwd.h> #include <pwd.h>
#include <unistd.h> #include <unistd.h>
#include <boost/filesystem/fstream.hpp> #include <fstream>
#include <cstring>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/misc/strings/lower.hpp> #include <components/misc/strings/lower.hpp>
namespace namespace
{ {
boost::filesystem::path getUserHome() std::filesystem::path getUserHome()
{ {
const char* dir = getenv("HOME"); const char* dir = getenv("HOME");
if (dir == nullptr) if (dir == nullptr)
@ -23,17 +24,17 @@ namespace
} }
} }
if (dir == nullptr) if (dir == nullptr)
return boost::filesystem::path(); return std::filesystem::path();
else else
return boost::filesystem::path(dir); return std::filesystem::path(dir);
} }
boost::filesystem::path getEnv(const std::string& envVariable, const boost::filesystem::path& fallback) std::filesystem::path getEnv(const std::string& envVariable, const std::filesystem::path& fallback)
{ {
const char* result = getenv(envVariable.c_str()); const char* result = getenv(envVariable.c_str());
if (!result) if (!result)
return fallback; return fallback;
boost::filesystem::path dir(result); std::filesystem::path dir(result);
if (dir.empty()) if (dir.empty())
return fallback; return fallback;
else else
@ -50,44 +51,44 @@ namespace Files
LinuxPath::LinuxPath(const std::string& application_name) LinuxPath::LinuxPath(const std::string& application_name)
: mName(application_name) : mName(application_name)
{ {
boost::filesystem::path localPath = getLocalPath(); std::filesystem::path localPath = getLocalPath();
if (chdir(localPath.string().c_str()) != 0) if (chdir(localPath.string().c_str()) != 0)
Log(Debug::Warning) << "Error " << errno << " when changing current directory"; Log(Debug::Warning) << "Error " << errno << " when changing current directory";
} }
boost::filesystem::path LinuxPath::getUserConfigPath() const std::filesystem::path LinuxPath::getUserConfigPath() const
{ {
return getEnv("XDG_CONFIG_HOME", getUserHome() / ".config") / mName; return getEnv("XDG_CONFIG_HOME", getUserHome() / ".config") / mName;
} }
boost::filesystem::path LinuxPath::getUserDataPath() const std::filesystem::path LinuxPath::getUserDataPath() const
{ {
return getEnv("XDG_DATA_HOME", getUserHome() / ".local/share") / mName; return getEnv("XDG_DATA_HOME", getUserHome() / ".local/share") / mName;
} }
boost::filesystem::path LinuxPath::getCachePath() const std::filesystem::path LinuxPath::getCachePath() const
{ {
return getEnv("XDG_CACHE_HOME", getUserHome() / ".cache") / mName; return getEnv("XDG_CACHE_HOME", getUserHome() / ".cache") / mName;
} }
boost::filesystem::path LinuxPath::getGlobalConfigPath() const std::filesystem::path LinuxPath::getGlobalConfigPath() const
{ {
boost::filesystem::path globalPath(GLOBAL_CONFIG_PATH); std::filesystem::path globalPath(GLOBAL_CONFIG_PATH);
return globalPath / mName; return globalPath / mName;
} }
boost::filesystem::path LinuxPath::getLocalPath() const std::filesystem::path LinuxPath::getLocalPath() const
{ {
boost::filesystem::path localPath("./"); std::filesystem::path localPath("./");
const char *statusPaths[] = {"/proc/self/exe", "/proc/self/file", "/proc/curproc/exe", "/proc/curproc/file"}; const char *statusPaths[] = {"/proc/self/exe", "/proc/self/file", "/proc/curproc/exe", "/proc/curproc/file"};
for(const char *path : statusPaths) for(const char *path : statusPaths)
{ {
boost::filesystem::path statusPath(path); std::filesystem::path statusPath(path);
if (!boost::filesystem::exists(statusPath)) continue; if (!std::filesystem::exists(statusPath)) continue;
statusPath = boost::filesystem::read_symlink(statusPath); statusPath = std::filesystem::read_symlink(statusPath);
if (!boost::filesystem::is_empty(statusPath)) if (!std::filesystem::is_empty(statusPath))
{ {
localPath = statusPath.parent_path() / "/"; localPath = statusPath.parent_path() / "/";
break; break;
@ -97,26 +98,26 @@ boost::filesystem::path LinuxPath::getLocalPath() const
return localPath; return localPath;
} }
boost::filesystem::path LinuxPath::getGlobalDataPath() const std::filesystem::path LinuxPath::getGlobalDataPath() const
{ {
boost::filesystem::path globalDataPath(GLOBAL_DATA_PATH); std::filesystem::path globalDataPath(GLOBAL_DATA_PATH);
return globalDataPath / mName; return globalDataPath / mName;
} }
boost::filesystem::path LinuxPath::getInstallPath() const std::filesystem::path LinuxPath::getInstallPath() const
{ {
boost::filesystem::path installPath; std::filesystem::path installPath;
boost::filesystem::path homePath = getUserHome(); std::filesystem::path homePath = getUserHome();
if (!homePath.empty()) if (!homePath.empty())
{ {
boost::filesystem::path wineDefaultRegistry(homePath); std::filesystem::path wineDefaultRegistry(homePath);
wineDefaultRegistry /= ".wine/system.reg"; wineDefaultRegistry /= ".wine/system.reg";
if (boost::filesystem::is_regular_file(wineDefaultRegistry)) if (std::filesystem::is_regular_file(wineDefaultRegistry))
{ {
boost::filesystem::ifstream file(wineDefaultRegistry); std::ifstream file(wineDefaultRegistry);
bool isRegEntry = false; bool isRegEntry = false;
std::string line; std::string line;
std::string mwpath; std::string mwpath;
@ -163,7 +164,7 @@ boost::filesystem::path LinuxPath::getInstallPath() const
installPath /= ".wine/dosdevices/"; installPath /= ".wine/dosdevices/";
installPath /= mwpath; installPath /= mwpath;
if (!boost::filesystem::is_directory(installPath)) if (!std::filesystem::is_directory(installPath))
{ {
installPath.clear(); installPath.clear();
} }

@ -3,7 +3,7 @@
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) #if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
#include <boost/filesystem.hpp> #include <filesystem>
/** /**
* \namespace Files * \namespace Files
@ -21,35 +21,35 @@ struct LinuxPath
/** /**
* \brief Return path to the user directory. * \brief Return path to the user directory.
*/ */
boost::filesystem::path getUserConfigPath() const; std::filesystem::path getUserConfigPath() const;
boost::filesystem::path getUserDataPath() const; std::filesystem::path getUserDataPath() const;
/** /**
* \brief Return path to the global (system) directory where config files can be placed. * \brief Return path to the global (system) directory where config files can be placed.
*/ */
boost::filesystem::path getGlobalConfigPath() const; std::filesystem::path getGlobalConfigPath() const;
/** /**
* \brief Return path to the runtime configuration directory which is the * \brief Return path to the runtime configuration directory which is the
* place where an application was started. * place where an application was started.
*/ */
boost::filesystem::path getLocalPath() const; std::filesystem::path getLocalPath() const;
/** /**
* \brief Return path to the global (system) directory where game files can be placed. * \brief Return path to the global (system) directory where game files can be placed.
*/ */
boost::filesystem::path getGlobalDataPath() const; std::filesystem::path getGlobalDataPath() const;
/** /**
* \brief * \brief
*/ */
boost::filesystem::path getCachePath() const; std::filesystem::path getCachePath() const;
/** /**
* \brief Gets the path of the installed Morrowind version if there is one. * \brief Gets the path of the installed Morrowind version if there is one.
*/ */
boost::filesystem::path getInstallPath() const; std::filesystem::path getInstallPath() const;
std::string mName; std::string mName;
}; };

@ -5,13 +5,13 @@
#include <cstdlib> #include <cstdlib>
#include <pwd.h> #include <pwd.h>
#include <unistd.h> #include <unistd.h>
#include <boost/filesystem/fstream.hpp> #include <filesystem>
#include <components/misc/strings/lower.hpp> #include <components/misc/strings/lower.hpp>
namespace namespace
{ {
boost::filesystem::path getUserHome() std::filesystem::path getUserHome()
{ {
const char* dir = getenv("HOME"); const char* dir = getenv("HOME");
if (dir == nullptr) if (dir == nullptr)
@ -23,9 +23,9 @@ namespace
} }
} }
if (dir == nullptr) if (dir == nullptr)
return boost::filesystem::path(); return std::filesystem::path();
else else
return boost::filesystem::path(dir); return std::filesystem::path(dir);
} }
} }
@ -37,60 +37,60 @@ MacOsPath::MacOsPath(const std::string& application_name)
{ {
} }
boost::filesystem::path MacOsPath::getUserConfigPath() const std::filesystem::path MacOsPath::getUserConfigPath() const
{ {
boost::filesystem::path userPath (getUserHome()); std::filesystem::path userPath (getUserHome());
userPath /= "Library/Preferences/"; userPath /= "Library/Preferences/";
return userPath / mName; return userPath / mName;
} }
boost::filesystem::path MacOsPath::getUserDataPath() const std::filesystem::path MacOsPath::getUserDataPath() const
{ {
boost::filesystem::path userPath (getUserHome()); std::filesystem::path userPath (getUserHome());
userPath /= "Library/Application Support/"; userPath /= "Library/Application Support/";
return userPath / mName; return userPath / mName;
} }
boost::filesystem::path MacOsPath::getGlobalConfigPath() const std::filesystem::path MacOsPath::getGlobalConfigPath() const
{ {
boost::filesystem::path globalPath("/Library/Preferences/"); std::filesystem::path globalPath("/Library/Preferences/");
return globalPath / mName; return globalPath / mName;
} }
boost::filesystem::path MacOsPath::getCachePath() const std::filesystem::path MacOsPath::getCachePath() const
{ {
boost::filesystem::path userPath (getUserHome()); std::filesystem::path userPath (getUserHome());
userPath /= "Library/Caches"; userPath /= "Library/Caches";
return userPath / mName; return userPath / mName;
} }
boost::filesystem::path MacOsPath::getLocalPath() const std::filesystem::path MacOsPath::getLocalPath() const
{ {
return boost::filesystem::path("../Resources/"); return std::filesystem::path("../Resources/");
} }
boost::filesystem::path MacOsPath::getGlobalDataPath() const std::filesystem::path MacOsPath::getGlobalDataPath() const
{ {
boost::filesystem::path globalDataPath("/Library/Application Support/"); std::filesystem::path globalDataPath("/Library/Application Support/");
return globalDataPath / mName; return globalDataPath / mName;
} }
boost::filesystem::path MacOsPath::getInstallPath() const std::filesystem::path MacOsPath::getInstallPath() const
{ {
boost::filesystem::path installPath; std::filesystem::path installPath;
boost::filesystem::path homePath = getUserHome(); std::filesystem::path homePath = getUserHome();
if (!homePath.empty()) if (!homePath.empty())
{ {
boost::filesystem::path wineDefaultRegistry(homePath); std::filesystem::path wineDefaultRegistry(homePath);
wineDefaultRegistry /= ".wine/system.reg"; wineDefaultRegistry /= ".wine/system.reg";
if (boost::filesystem::is_regular_file(wineDefaultRegistry)) if (std::filesystem::is_regular_file(wineDefaultRegistry))
{ {
boost::filesystem::ifstream file(wineDefaultRegistry); std::filesystem::ifstream file(wineDefaultRegistry);
bool isRegEntry = false; bool isRegEntry = false;
std::string line; std::string line;
std::string mwpath; std::string mwpath;
@ -136,7 +136,7 @@ boost::filesystem::path MacOsPath::getInstallPath() const
installPath /= ".wine/dosdevices/"; installPath /= ".wine/dosdevices/";
installPath /= mwpath; installPath /= mwpath;
if (!boost::filesystem::is_directory(installPath)) if (!std::filesystem::is_directory(installPath))
{ {
installPath.clear(); installPath.clear();
} }

@ -3,7 +3,7 @@
#if defined(macintosh) || defined(Macintosh) || defined(__APPLE__) || defined(__MACH__) #if defined(macintosh) || defined(Macintosh) || defined(__APPLE__) || defined(__MACH__)
#include <boost/filesystem.hpp> #include <filesystem>
/** /**
* \namespace Files * \namespace Files
@ -21,42 +21,42 @@ struct MacOsPath
/** /**
* \brief Return path to the local directory. * \brief Return path to the local directory.
* *
* \return boost::filesystem::path * \return std::filesystem::path
*/ */
boost::filesystem::path getUserConfigPath() const; std::filesystem::path getUserConfigPath() const;
boost::filesystem::path getUserDataPath() const; std::filesystem::path getUserDataPath() const;
/** /**
* \brief Return path to the global (system) directory. * \brief Return path to the global (system) directory.
* *
* \return boost::filesystem::path * \return std::filesystem::path
*/ */
boost::filesystem::path getGlobalConfigPath() const; std::filesystem::path getGlobalConfigPath() const;
/** /**
* \brief Return path to the runtime directory which is the * \brief Return path to the runtime directory which is the
* place where an application was started. * place where an application was started.
* *
* \return boost::filesystem::path * \return std::filesystem::path
*/ */
boost::filesystem::path getLocalPath() const; std::filesystem::path getLocalPath() const;
/** /**
* \brief * \brief
* *
* \return boost::filesystem::path * \return std::filesystem::path
*/ */
boost::filesystem::path getCachePath() const; std::filesystem::path getCachePath() const;
/** /**
* \brief * \brief
* *
* \return boost::filesystem::path * \return std::filesystem::path
*/ */
boost::filesystem::path getGlobalDataPath() const; std::filesystem::path getGlobalDataPath() const;
boost::filesystem::path getInstallPath() const; std::filesystem::path getInstallPath() const;
std::string mName; std::string mName;
}; };

@ -1,6 +1,6 @@
#include "multidircollection.hpp" #include "multidircollection.hpp"
#include <boost/filesystem.hpp> #include <filesystem>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
@ -26,19 +26,18 @@ namespace Files
{ {
NameEqual equal (!foldCase); NameEqual equal (!foldCase);
for (PathContainer::const_iterator iter = directories.begin(); for (const auto & directory : directories)
iter!=directories.end(); ++iter)
{ {
if (!boost::filesystem::is_directory(*iter)) if (!std::filesystem::is_directory(directory))
{ {
Log(Debug::Info) << "Skipping invalid directory: " << (*iter).string(); Log(Debug::Info) << "Skipping invalid directory: " << directory.string();
continue; continue;
} }
for (boost::filesystem::directory_iterator dirIter(*iter); for (std::filesystem::directory_iterator dirIter(directory);
dirIter != boost::filesystem::directory_iterator(); ++dirIter) dirIter != std::filesystem::directory_iterator(); ++dirIter)
{ {
boost::filesystem::path path = *dirIter; std::filesystem::path path = *dirIter;
if (!equal (extension, path.extension().string())) if (!equal (extension, path.extension().string()))
continue; continue;
@ -65,7 +64,7 @@ namespace Files
} }
} }
boost::filesystem::path MultiDirCollection::getPath (const std::string& file) const std::filesystem::path MultiDirCollection::getPath (const std::string& file) const
{ {
TIter iter = mFiles.find (file); TIter iter = mFiles.find (file);

@ -5,14 +5,13 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <cctype> #include <cctype>
#include <filesystem>
#include <boost/filesystem/path.hpp>
#include <components/misc/strings/algorithm.hpp> #include <components/misc/strings/algorithm.hpp>
namespace Files namespace Files
{ {
typedef std::vector<boost::filesystem::path> PathContainer; typedef std::vector<std::filesystem::path> PathContainer;
struct NameLess struct NameLess
{ {
@ -37,7 +36,7 @@ namespace Files
{ {
public: public:
typedef std::map<std::string, boost::filesystem::path, NameLess> TContainer; typedef std::map<std::string, std::filesystem::path, NameLess> TContainer;
typedef TContainer::const_iterator TIter; typedef TContainer::const_iterator TIter;
private: private:
@ -53,7 +52,7 @@ namespace Files
/// contain the leading dot. /// contain the leading dot.
/// \param foldCase Ignore filename case /// \param foldCase Ignore filename case
boost::filesystem::path getPath (const std::string& file) const; std::filesystem::path getPath (const std::string& file) const;
///< Return full path (including filename) of \a file. ///< Return full path (including filename) of \a file.
/// ///
/// If the file does not exist, an exception is thrown. \a file must include /// If the file does not exist, an exception is thrown. \a file must include

@ -38,79 +38,79 @@ WindowsPath::WindowsPath(const std::string& application_name)
with UTF-8 encoding (generated for empty name from boost::locale) with UTF-8 encoding (generated for empty name from boost::locale)
to handle Unicode in platform-agnostic way using std::string. to handle Unicode in platform-agnostic way using std::string.
See boost::filesystem and boost::locale reference for details. See std::filesystem and boost::locale reference for details.
*/ */
boost::filesystem::path::imbue(boost::locale::generator().generate("")); std::filesystem::path::imbue(boost::locale::generator().generate(""));
boost::filesystem::path localPath = getLocalPath(); std::filesystem::path localPath = getLocalPath();
if (!SetCurrentDirectoryA(localPath.string().c_str())) if (!SetCurrentDirectoryA(localPath.string().c_str()))
Log(Debug::Warning) << "Error " << GetLastError() << " when changing current directory"; Log(Debug::Warning) << "Error " << GetLastError() << " when changing current directory";
} }
boost::filesystem::path WindowsPath::getUserConfigPath() const std::filesystem::path WindowsPath::getUserConfigPath() const
{ {
boost::filesystem::path userPath("."); std::filesystem::path userPath(".");
WCHAR path[MAX_PATH + 1]; WCHAR path[MAX_PATH + 1];
memset(path, 0, sizeof(path)); memset(path, 0, sizeof(path));
if(SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, nullptr, 0, path))) if(SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, nullptr, 0, path)))
{ {
userPath = boost::filesystem::path(bconv::utf_to_utf<char>(path)); userPath = std::filesystem::path(bconv::utf_to_utf<char>(path));
} }
return userPath / "My Games" / mName; return userPath / "My Games" / mName;
} }
boost::filesystem::path WindowsPath::getUserDataPath() const std::filesystem::path WindowsPath::getUserDataPath() const
{ {
// Have some chaos, windows people! // Have some chaos, windows people!
return getUserConfigPath(); return getUserConfigPath();
} }
boost::filesystem::path WindowsPath::getGlobalConfigPath() const std::filesystem::path WindowsPath::getGlobalConfigPath() const
{ {
boost::filesystem::path globalPath("."); std::filesystem::path globalPath(".");
WCHAR path[MAX_PATH + 1]; WCHAR path[MAX_PATH + 1];
memset(path, 0, sizeof(path)); memset(path, 0, sizeof(path));
if(SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_PROGRAM_FILES | CSIDL_FLAG_CREATE, nullptr, 0, path))) if(SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_PROGRAM_FILES | CSIDL_FLAG_CREATE, nullptr, 0, path)))
{ {
globalPath = boost::filesystem::path(bconv::utf_to_utf<char>(path)); globalPath = std::filesystem::path(bconv::utf_to_utf<char>(path));
} }
return globalPath / mName; return globalPath / mName;
} }
boost::filesystem::path WindowsPath::getLocalPath() const std::filesystem::path WindowsPath::getLocalPath() const
{ {
boost::filesystem::path localPath("./"); std::filesystem::path localPath("./");
WCHAR path[MAX_PATH + 1]; WCHAR path[MAX_PATH + 1];
memset(path, 0, sizeof(path)); memset(path, 0, sizeof(path));
if (GetModuleFileNameW(nullptr, path, MAX_PATH + 1) > 0) if (GetModuleFileNameW(nullptr, path, MAX_PATH + 1) > 0)
{ {
localPath = boost::filesystem::path(bconv::utf_to_utf<char>(path)).parent_path() / "/"; localPath = std::filesystem::path(bconv::utf_to_utf<char>(path)).parent_path() / "/";
} }
// lookup exe path // lookup exe path
return localPath; return localPath;
} }
boost::filesystem::path WindowsPath::getGlobalDataPath() const std::filesystem::path WindowsPath::getGlobalDataPath() const
{ {
return getGlobalConfigPath(); return getGlobalConfigPath();
} }
boost::filesystem::path WindowsPath::getCachePath() const std::filesystem::path WindowsPath::getCachePath() const
{ {
return getUserConfigPath() / "cache"; return getUserConfigPath() / "cache";
} }
boost::filesystem::path WindowsPath::getInstallPath() const std::filesystem::path WindowsPath::getInstallPath() const
{ {
boost::filesystem::path installPath(""); std::filesystem::path installPath("");
HKEY hKey; HKEY hKey;

@ -3,7 +3,7 @@
#if defined(_WIN32) || defined(__WINDOWS__) #if defined(_WIN32) || defined(__WINDOWS__)
#include <boost/filesystem.hpp> #include <filesystem>
/** /**
* \namespace Files * \namespace Files
@ -27,47 +27,47 @@ struct WindowsPath
* \brief Returns user path i.e.: * \brief Returns user path i.e.:
* "X:\Documents And Settings\<User name>\My Documents\My Games\" * "X:\Documents And Settings\<User name>\My Documents\My Games\"
* *
* \return boost::filesystem::path * \return std::filesystem::path
*/ */
boost::filesystem::path getUserConfigPath() const; std::filesystem::path getUserConfigPath() const;
boost::filesystem::path getUserDataPath() const; std::filesystem::path getUserDataPath() const;
/** /**
* \brief Returns "X:\Program Files\" * \brief Returns "X:\Program Files\"
* *
* \return boost::filesystem::path * \return std::filesystem::path
*/ */
boost::filesystem::path getGlobalConfigPath() const; std::filesystem::path getGlobalConfigPath() const;
/** /**
* \brief Return local path which is a location where * \brief Return local path which is a location where
* an application was started * an application was started
* *
* \return boost::filesystem::path * \return std::filesystem::path
*/ */
boost::filesystem::path getLocalPath() const; std::filesystem::path getLocalPath() const;
/** /**
* \brief * \brief
* *
* \return boost::filesystem::path * \return std::filesystem::path
*/ */
boost::filesystem::path getCachePath() const; std::filesystem::path getCachePath() const;
/** /**
* \brief Return same path like getGlobalPath * \brief Return same path like getGlobalPath
* *
* \return boost::filesystem::path * \return std::filesystem::path
*/ */
boost::filesystem::path getGlobalDataPath() const; std::filesystem::path getGlobalDataPath() const;
/** /**
* \brief Gets the path of the installed Morrowind version if there is one. * \brief Gets the path of the installed Morrowind version if there is one.
* *
* \return boost::filesystem::path * \return std::filesystem::path
*/ */
boost::filesystem::path getInstallPath() const; std::filesystem::path getInstallPath() const;
std::string mName; std::string mName;
}; };

@ -0,0 +1,17 @@
#ifndef OPENMW_COMPONENTS_MISC_TIMECONVERT_H
#define OPENMW_COMPONENTS_MISC_TIMECONVERT_H
namespace Misc
{
// Very ugly hack to go from std::chrono::file_clock to any other clock, can be replaced with better solution in C++20
// https://stackoverflow.com/questions/35282308/convert-between-c11-clocks
template <typename DstTimePointT, typename SrcTimePointT, typename DstClockT = typename DstTimePointT::clock, typename SrcClockT = typename SrcTimePointT::clock>
inline DstTimePointT clockCast (const SrcTimePointT tp)
{
const auto src_now = SrcClockT::now();
const auto dst_now = DstClockT::now();
return dst_now + (tp - src_now);
}
} // namespace Misc
#endif

@ -8,7 +8,7 @@ namespace osgMyGUI
{ {
void CustomLogListener::open() void CustomLogListener::open()
{ {
mStream.open(boost::filesystem::path(mFileName), std::ios_base::out); mStream.open(std::filesystem::path(mFileName), std::ios_base::out);
if (!mStream.is_open()) if (!mStream.is_open())
Log(Debug::Error) << "Unable to create MyGUI log with path " << mFileName; Log(Debug::Error) << "Unable to create MyGUI log with path " << mFileName;
} }

@ -2,7 +2,8 @@
#define OPENMW_COMPONENTS_MYGUIPLATFORM_LOGLISTENER_H #define OPENMW_COMPONENTS_MYGUIPLATFORM_LOGLISTENER_H
#include <string> #include <string>
#include <boost/filesystem/fstream.hpp> #include <filesystem>
#include <fstream>
#include <MyGUI_ILogListener.h> #include <MyGUI_ILogListener.h>
#include <MyGUI_LogSource.h> #include <MyGUI_LogSource.h>
@ -33,7 +34,7 @@ namespace osgMyGUI
const std::string& getFileName() const { return mFileName; } const std::string& getFileName() const { return mFileName; }
private: private:
boost::filesystem::ofstream mStream; std::ofstream mStream;
std::string mFileName; std::string mFileName;
}; };

@ -24,7 +24,7 @@ void Manager::clear()
std::string Manager::load(const Files::ConfigurationManager& cfgMgr, bool loadEditorSettings) std::string Manager::load(const Files::ConfigurationManager& cfgMgr, bool loadEditorSettings)
{ {
SettingsFileParser parser; SettingsFileParser parser;
const std::vector<boost::filesystem::path>& paths = cfgMgr.getActiveConfigPaths(); const std::vector<std::filesystem::path>& paths = cfgMgr.getActiveConfigPaths();
if (paths.empty()) if (paths.empty())
throw std::runtime_error("No config dirs! ConfigurationManager::readConfiguration must be called first."); throw std::runtime_error("No config dirs! ConfigurationManager::readConfiguration must be called first.");

@ -40,17 +40,16 @@ namespace VFS
if (useLooseFiles) if (useLooseFiles)
{ {
std::set<std::filesystem::path> seen; std::set<std::filesystem::path> seen;
for (Files::PathContainer::const_iterator iter = dataDirs.begin(); iter != dataDirs.end(); ++iter) for (const auto &dataDir : dataDirs)
{ {
// TODO(jvoisin) Get rid of `->native()` when we move PathContainer from boost::filesystem to std::filesystem. if (seen.insert(dataDir).second)
if (seen.insert(iter->native()).second)
{ {
Log(Debug::Info) << "Adding data directory " << iter->string(); Log(Debug::Info) << "Adding data directory " << dataDir;
// Last data dir has the highest priority // Last data dir has the highest priority
vfs->addArchive(std::make_unique<FileSystemArchive>(iter->string())); vfs->addArchive(std::make_unique<FileSystemArchive>(dataDir));
} }
else else
Log(Debug::Info) << "Ignoring duplicate data directory " << iter->string(); Log(Debug::Info) << "Ignoring duplicate data directory " << dataDir;
} }
} }

Loading…
Cancel
Save