From eba8439295691c94680a2e9c7019d849a5937743 Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Mon, 20 Oct 2025 13:45:11 +0200 Subject: [PATCH] Replace boost::filesystem std::filyestem Bumping the minimum version of macOS to 10.15 for spidermonky [1] also allows us to use std::filesystem instead of boosts implementation. [1] f14a98e26f9cfdc596743a015378fd8491b10256 Signed-off-by: Ralph Sennhauser --- build/premake/extern_libs5.lua | 15 --------------- source/graphics/TextureManager.cpp | 6 +++--- source/lib/file/file_system.cpp | 16 ++++++---------- source/simulation2/components/ICmpAIManager.cpp | 6 +++--- .../tinygettext/src/unix_file_system.cpp | 4 ++-- 5 files changed, 14 insertions(+), 33 deletions(-) diff --git a/build/premake/extern_libs5.lua b/build/premake/extern_libs5.lua index ec2921d115..b9fdd7098f 100644 --- a/build/premake/extern_libs5.lua +++ b/build/premake/extern_libs5.lua @@ -224,21 +224,6 @@ extern_lib_defs = { externalincludedirs { "/usr/local/include" } end end, - link_settings = function() - if os.istarget("windows") or os.istarget("macosx") then - if os.istarget("windows") then - defines { 'BOOST_LIB_TOOLSET="vc143"' } - end - add_default_lib_paths("boost") - end - add_default_links({ - -- The following are not strictly link dependencies on all systems, but - -- are included for compatibility with different versions of Boost - android_names = { "boost_filesystem-gcc-mt" }, - unix_names = { os.findlib("boost_filesystem-mt") and "boost_filesystem-mt" or "boost_filesystem" }, - osx_names = { "boost_filesystem" }, - }) - end, }, comsuppw = { link_settings = function() diff --git a/source/graphics/TextureManager.cpp b/source/graphics/TextureManager.cpp index 72b77c083f..f3afdd1ae1 100644 --- a/source/graphics/TextureManager.cpp +++ b/source/graphics/TextureManager.cpp @@ -43,9 +43,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -792,11 +792,11 @@ public: */ CTextureConverter::Settings GetConverterSettings(const CTexturePtr& texture) { - boost::filesystem::path srcPath = texture->m_Properties.m_Path.string(); + std::filesystem::path srcPath = texture->m_Properties.m_Path.string(); std::vector files; VfsPath p; - for (boost::filesystem::path::iterator it = srcPath.begin(); it != srcPath.end(); ++it) + for (std::filesystem::path::iterator it = srcPath.begin(); it != srcPath.end(); ++it) { VfsPath settingsPath = p / "textures.xml"; m_HotloadFiles[settingsPath].insert(texture); diff --git a/source/lib/file/file_system.cpp b/source/lib/file/file_system.cpp index 9991f64e1a..d5d1918636 100644 --- a/source/lib/file/file_system.cpp +++ b/source/lib/file/file_system.cpp @@ -32,10 +32,10 @@ #include "lib/sysdep/filesystem.h" #include "lib/sysdep/os.h" -#include #include #include #include +#include #include #include @@ -217,9 +217,9 @@ Status RenameFile(const OsPath& path, const OsPath& newPath) try { - boost::filesystem::rename(boost::filesystem::path(path.string()), boost::filesystem::path(newPath.string())); + std::filesystem::rename(std::filesystem::path(path.string()), std::filesystem::path(newPath.string())); } - catch (boost::filesystem::filesystem_error& err) + catch (std::filesystem::filesystem_error& err) { debug_printf("RenameFile: failed to rename %s to %s.\n%s\n", path.string8().c_str(), path.string8().c_str(), err.what()); return ERR::EXCEPTION; @@ -237,15 +237,11 @@ Status CopyFile(const OsPath& path, const OsPath& newPath, bool override_if_exis try { if(override_if_exists) -#if BOOST_VERSION >=107400 - boost::filesystem::copy_file(boost::filesystem::path(path.string()), boost::filesystem::path(newPath.string()), boost::filesystem::copy_options::overwrite_existing); -#else - boost::filesystem::copy_file(boost::filesystem::path(path.string()), boost::filesystem::path(newPath.string()), boost::filesystem::copy_option::overwrite_if_exists); -#endif + std::filesystem::copy_file(std::filesystem::path(path.string()), std::filesystem::path(newPath.string()), std::filesystem::copy_options::overwrite_existing); else - boost::filesystem::copy_file(boost::filesystem::path(path.string()), boost::filesystem::path(newPath.string())); + std::filesystem::copy_file(std::filesystem::path(path.string()), std::filesystem::path(newPath.string())); } - catch(boost::filesystem::filesystem_error& err) + catch(std::filesystem::filesystem_error& err) { debug_printf("CopyFile: failed to copy %s to %s.\n%s\n", path.string8().c_str(), path.string8().c_str(), err.what()); return ERR::EXCEPTION; diff --git a/source/simulation2/components/ICmpAIManager.cpp b/source/simulation2/components/ICmpAIManager.cpp index b54e80a351..17820a5252 100644 --- a/source/simulation2/components/ICmpAIManager.cpp +++ b/source/simulation2/components/ICmpAIManager.cpp @@ -31,7 +31,7 @@ #include "scriptinterface/ScriptRequest.h" #include "simulation2/system/InterfaceScripted.h" -#include +#include #include #include #include @@ -72,8 +72,8 @@ public: ScriptRequest rq(self->m_ScriptInterface); // Extract the 3rd component of the path (i.e. the directory after simulation/ai/) - boost::filesystem::path components = pathname.string(); - boost::filesystem::path::iterator it = components.begin(); + std::filesystem::path components = pathname.string(); + std::filesystem::path::iterator it = components.begin(); std::advance(it, 2); std::wstring dirname = it->wstring(); diff --git a/source/third_party/tinygettext/src/unix_file_system.cpp b/source/third_party/tinygettext/src/unix_file_system.cpp index 5760f612b2..0b41b62109 100644 --- a/source/third_party/tinygettext/src/unix_file_system.cpp +++ b/source/third_party/tinygettext/src/unix_file_system.cpp @@ -24,7 +24,7 @@ #include "tinygettext/unix_file_system.hpp" -#include +#include #include #include @@ -38,7 +38,7 @@ std::vector UnixFileSystem::open_directory(const std::string& pathname) { std::vector files; - for(auto const& p : boost::filesystem::directory_iterator(pathname)) + for(auto const& p : std::filesystem::directory_iterator(pathname)) { files.push_back(p.path().filename().string()); }