Replaced boost::filesystem with std::filesystem

Changes based on f0f6f61cab
dev
Tomasz Kapuściński 2023-08-09 17:04:09 +02:00
parent 550193e570
commit 0ef77132a0
6 changed files with 25 additions and 46 deletions

View File

@ -334,7 +334,7 @@ set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME ${USE_STATIC_RUNTIME})
set(Boost_ADDITIONALVERSION "1.51" "1.51.0")
find_package(Boost COMPONENTS system filesystem regex REQUIRED)
find_package(Boost COMPONENTS system regex REQUIRED)
set(GLEW_USE_STATIC_LIBS ${GLEW_STATIC})
find_package(GLEW REQUIRED)

View File

@ -504,7 +504,6 @@ target_link_libraries(colobotbase PUBLIC
GLEW::GLEW
glm::glm
Boost::headers
Boost::filesystem
Boost::regex
PhysFS::PhysFS
SndFile::sndfile

View File

@ -32,12 +32,10 @@
#include "level/parser/parser.h"
#include <algorithm>
#include <filesystem>
#include <map>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
using namespace boost::filesystem;
CModManager::CModManager(CApplication* app, CPathManager* pathManager)
: m_app{app},
m_pathManager{pathManager}
@ -74,7 +72,7 @@ void CModManager::FindMods()
std::map<std::string, std::string> modPaths;
for (const auto& path : rawPaths)
{
auto modName = boost::filesystem::path(path).stem().string();
auto modName = std::filesystem::path(path).stem().string();
modPaths.insert(std::make_pair(modName, path));
}

View File

@ -18,24 +18,23 @@
*/
#include "app/app.h"
#include "app/pathman.h"
#include "common/config.h"
#include "app/app.h"
#include "common/logger.h"
#include "common/resources/resourcemanager.h"
#include "common/system/system.h"
#ifdef PLATFORM_WINDOWS
#include "common/system/system_windows.h"
#endif
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <filesystem>
CPathManager::CPathManager(CSystemUtils* systemUtils)
: m_dataPath(systemUtils->GetDataPath())
@ -81,12 +80,9 @@ const std::string& CPathManager::GetSavePath()
std::string CPathManager::VerifyPaths()
{
#if PLATFORM_WINDOWS
boost::filesystem::path dataPath(CSystemUtilsWindows::UTF8_Decode(m_dataPath));
#else
boost::filesystem::path dataPath(m_dataPath);
#endif
if (! (boost::filesystem::exists(dataPath) && boost::filesystem::is_directory(dataPath)) )
std::filesystem::path dataPath = std::filesystem::u8path(m_dataPath);
if (! (std::filesystem::exists(dataPath) && std::filesystem::is_directory(dataPath)) )
{
GetLogger()->Error("Data directory '%s' doesn't exist or is not a directory\n", m_dataPath.c_str());
return std::string("Could not read from data directory:\n") +
@ -94,23 +90,15 @@ std::string CPathManager::VerifyPaths()
std::string("Please check your installation, or supply a valid data directory by -datadir option.");
}
#if PLATFORM_WINDOWS
boost::filesystem::path langPath(CSystemUtilsWindows::UTF8_Decode(m_langPath));
#else
boost::filesystem::path langPath(m_langPath);
#endif
if (! (boost::filesystem::exists(langPath) && boost::filesystem::is_directory(langPath)) )
std::filesystem::path langPath = std::filesystem::u8path(m_langPath);
if (! (std::filesystem::exists(langPath) && std::filesystem::is_directory(langPath)) )
{
GetLogger()->Warn("Language path '%s' is invalid, assuming translation files not installed\n", m_langPath.c_str());
}
#if PLATFORM_WINDOWS
boost::filesystem::create_directories(CSystemUtilsWindows::UTF8_Decode(m_savePath));
boost::filesystem::create_directories(CSystemUtilsWindows::UTF8_Decode(m_savePath+"/mods"));
#else
boost::filesystem::create_directories(m_savePath);
boost::filesystem::create_directories(m_savePath+"/mods");
#endif
std::filesystem::create_directories(std::filesystem::u8path(m_savePath));
std::filesystem::create_directories(std::filesystem::u8path(m_savePath + "/mods"));
return "";
}
@ -159,9 +147,10 @@ std::vector<std::string> CPathManager::FindMods() const
}
}
GetLogger()->Info("Additional mod paths:\n");
for (const auto& modPath : m_mods)
{
if (boost::filesystem::exists(modPath))
if (std::filesystem::exists(modPath))
{
GetLogger()->Info(" * %s\n", modPath.c_str());
mods.push_back(modPath);
@ -184,18 +173,11 @@ std::vector<std::string> CPathManager::FindModsInDir(const std::string &dir) con
std::vector<std::string> ret;
try
{
#if PLATFORM_WINDOWS
boost::filesystem::directory_iterator iterator(CSystemUtilsWindows::UTF8_Decode(dir));
#else
boost::filesystem::directory_iterator iterator(dir);
#endif
for(; iterator != boost::filesystem::directory_iterator(); ++iterator)
std::filesystem::directory_iterator iterator(std::filesystem::u8path(dir));
for(; iterator != std::filesystem::directory_iterator(); ++iterator)
{
#if PLATFORM_WINDOWS
ret.push_back(CSystemUtilsWindows::UTF8_Encode(iterator->path().wstring()));
#else
ret.push_back(iterator->path().string());
#endif
ret.push_back(iterator->path().u8string());
}
}
catch (std::exception &e)

View File

@ -28,7 +28,7 @@
#include <CoreFoundation/CFBundle.h>
#include <CoreServices/CoreServices.h>
#include <boost/filesystem.hpp>
#include <filesystem>
inline std::string CFStringRefToStdString(CFStringRef str) {
@ -78,7 +78,7 @@ void CSystemUtilsMacOSX::Init()
m_ASPath.append("/colobot/");
// Make sure the directory exists
boost::filesystem::create_directories(m_ASPath.c_str());
std::filesystem::create_directories(m_ASPath.c_str());
// Get the Resources bundle URL
CFBundleRef mainBundle = CFBundleGetMainBundle();

View File

@ -21,9 +21,9 @@
#include "common/logger.h"
#include <boost/filesystem.hpp>
#include <windows.h>
#include <filesystem>
void CSystemUtilsWindows::Init()
{
@ -132,7 +132,7 @@ std::string CSystemUtilsWindows::GetEnvVar(const std::string& name)
bool CSystemUtilsWindows::OpenPath(const std::string& path)
{
int result = system(("start explorer \"" + boost::filesystem::path(path).make_preferred().string() + "\"").c_str());
int result = system(("start explorer \"" + std::filesystem::u8path(path).make_preferred().string() + "\"").c_str());
if (result != 0)
{
GetLogger()->Error("Failed to open path: %s, error code: %i\n", path.c_str(), result);