diff --git a/CMakeLists.txt b/CMakeLists.txt index 4300f73c..767544df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c47bec95..1be04262 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -504,7 +504,6 @@ target_link_libraries(colobotbase PUBLIC GLEW::GLEW glm::glm Boost::headers - Boost::filesystem Boost::regex PhysFS::PhysFS SndFile::sndfile diff --git a/src/app/modman.cpp b/src/app/modman.cpp index 94a7be04..31b2d25f 100644 --- a/src/app/modman.cpp +++ b/src/app/modman.cpp @@ -32,12 +32,10 @@ #include "level/parser/parser.h" #include +#include #include -#include #include -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 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)); } diff --git a/src/app/pathman.cpp b/src/app/pathman.cpp index f9d2135b..d093984a 100644 --- a/src/app/pathman.cpp +++ b/src/app/pathman.cpp @@ -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 -#include + +#include 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 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 CPathManager::FindModsInDir(const std::string &dir) con std::vector 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) diff --git a/src/common/system/system_macosx.cpp b/src/common/system/system_macosx.cpp index d53cd406..a362e7c1 100644 --- a/src/common/system/system_macosx.cpp +++ b/src/common/system/system_macosx.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include 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(); diff --git a/src/common/system/system_windows.cpp b/src/common/system/system_windows.cpp index 7d9f3c70..97f6fb01 100644 --- a/src/common/system/system_windows.cpp +++ b/src/common/system/system_windows.cpp @@ -21,9 +21,9 @@ #include "common/logger.h" -#include #include +#include 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);