Base: Remove Boost-based filesystem and switch to standard <filesystem>

This commit is contained in:
tritao
2025-01-19 19:05:06 +00:00
committed by Chris Hennes
parent 5931e3295d
commit f7a0cece08
24 changed files with 144 additions and 110 deletions

View File

@@ -3,7 +3,7 @@ macro(SetupBoost)
set(_boost_TEST_VERSIONS ${Boost_ADDITIONAL_VERSIONS})
set (BOOST_COMPONENTS filesystem program_options regex system thread date_time)
set (BOOST_COMPONENTS program_options regex system thread date_time)
find_package(Boost ${BOOST_MIN_VERSION}
COMPONENTS ${BOOST_COMPONENTS} REQUIRED)

View File

@@ -34,9 +34,10 @@
#include <sys/mman.h>
#endif
#include <boost/filesystem.hpp>
#include <system_error>
#include <filesystem>
namespace boofs = boost::filesystem;
namespace stdfs = std::filesystem;
//================================================================================
/*!
@@ -168,8 +169,8 @@ bool SMESH_File::remove()
{
close();
boost::system::error_code err;
boofs::remove( _name, err );
std::error_code err;
stdfs::remove( _name, err );
_error = err.message();
return !err;
@@ -185,8 +186,8 @@ long SMESH_File::size()
{
if ( _size >= 0 ) return _size; // size of an open file
boost::system::error_code err;
boost::uintmax_t size = boofs::file_size( _name, err );
std::error_code err;
std::uintmax_t size = stdfs::file_size( _name, err );
_error = err.message();
return err ? -1 : (long) size;
@@ -200,8 +201,8 @@ long SMESH_File::size()
bool SMESH_File::exists()
{
boost::system::error_code err;
bool res = boofs::exists( _name, err );
std::error_code err;
bool res = stdfs::exists( _name, err );
_error = err.message();
return err ? false : res;
@@ -215,8 +216,8 @@ bool SMESH_File::exists()
bool SMESH_File::isDirectory()
{
boost::system::error_code err;
bool res = boofs::is_directory( _name, err );
std::error_code err;
bool res = stdfs::is_directory( _name, err );
_error = err.message();
return err ? false : res;

View File

@@ -25,7 +25,7 @@
#include "DriverGMF.hxx"
#include <boost/filesystem.hpp>
#include <filesystem>
extern "C"
{
@@ -55,7 +55,7 @@ namespace DriverGMF
bool isExtensionCorrect( const std::string& fileName )
{
std::string ext = boost::filesystem::path(fileName).extension().string();
std::string ext = std::filesystem::path(fileName).extension().string();
switch ( ext.size() ) {
case 5: return ( ext == ".mesh" || ext == ".solb" );
case 6: return ( ext == ".meshb" );

View File

@@ -3221,7 +3221,7 @@ QString findUserHomePath(const QString& userHome)
* Returns the path where to store application files to.
* If \a customHome is not empty it will be used, otherwise a path starting from \a stdHome will be used.
*/
boost::filesystem::path findPath(const QString& stdHome, const QString& customHome,
std::filesystem::path findPath(const QString& stdHome, const QString& customHome,
const std::vector<std::string>& paths, bool create)
{
QString dataPath = customHome;
@@ -3229,7 +3229,7 @@ boost::filesystem::path findPath(const QString& stdHome, const QString& customHo
dataPath = stdHome;
}
boost::filesystem::path appData(Base::FileInfo::stringToPath(dataPath.toStdString()));
std::filesystem::path appData(Base::FileInfo::stringToPath(dataPath.toStdString()));
// If a custom user home path is given then don't modify it
if (customHome.isEmpty()) {
@@ -3238,10 +3238,10 @@ boost::filesystem::path findPath(const QString& stdHome, const QString& customHo
}
// In order to write to our data path, we must create some directories, first.
if (create && !boost::filesystem::exists(appData) && !Py_IsInitialized()) {
if (create && !std::filesystem::exists(appData) && !Py_IsInitialized()) {
try {
boost::filesystem::create_directories(appData);
} catch (const boost::filesystem::filesystem_error& e) {
std::filesystem::create_directories(appData);
} catch (const std::filesystem::filesystem_error& e) {
throw Base::FileSystemError("Could not create directories. Failed with: " + e.code().message());
}
}
@@ -3373,13 +3373,13 @@ void Application::ExtractUserPath()
// User data path
//
boost::filesystem::path data = findPath(dataHome, customData, subdirs, true);
std::filesystem::path data = findPath(dataHome, customData, subdirs, true);
mConfig["UserAppData"] = Base::FileInfo::pathToString(data) + PATHSEP;
// User config path
//
boost::filesystem::path config = findPath(configHome, customHome, subdirs, true);
std::filesystem::path config = findPath(configHome, customHome, subdirs, true);
mConfig["UserConfigPath"] = Base::FileInfo::pathToString(config) + PATHSEP;
@@ -3387,14 +3387,14 @@ void Application::ExtractUserPath()
//
std::vector<std::string> cachedirs = subdirs;
cachedirs.emplace_back("Cache");
boost::filesystem::path cache = findPath(cacheHome, customTemp, cachedirs, true);
std::filesystem::path cache = findPath(cacheHome, customTemp, cachedirs, true);
mConfig["UserCachePath"] = Base::FileInfo::pathToString(cache) + PATHSEP;
// Set application tmp. directory
//
std::vector<std::string> empty;
boost::filesystem::path tmp = findPath(tempPath, customTemp, empty, true);
std::filesystem::path tmp = findPath(tempPath, customTemp, empty, true);
mConfig["AppTempPath"] = Base::FileInfo::pathToString(tmp) + PATHSEP;
@@ -3402,7 +3402,7 @@ void Application::ExtractUserPath()
//
std::vector<std::string> macrodirs = subdirs;
macrodirs.emplace_back("Macro");
boost::filesystem::path macro = findPath(dataHome, customData, macrodirs, true);
std::filesystem::path macro = findPath(dataHome, customData, macrodirs, true);
mConfig["UserMacroPath"] = Base::FileInfo::pathToString(macro) + PATHSEP;
}

View File

@@ -60,7 +60,7 @@ recompute path. Also, it enables more complicated dependencies beyond trees.
#ifndef _PreComp_
#include <bitset>
#include <stack>
#include <boost/filesystem.hpp>
#include <filesystem>
#endif
#include <boost/algorithm/string.hpp>
@@ -131,7 +131,7 @@ using namespace zipios;
#define FC_LOGFEATUREUPDATE
#endif
namespace fs = boost::filesystem;
namespace fs = std::filesystem;
namespace App
{

View File

@@ -57,7 +57,7 @@ directly. If you did not intend to use a system-defined macro
#endif
using namespace App;
namespace fs = boost::filesystem;
namespace fs = std::filesystem;
#ifndef XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_QUALIFIER
using namespace XERCES_CPP_NAMESPACE;
@@ -246,7 +246,7 @@ std::string Metadata::classname() const
return _classname;
}
boost::filesystem::path Metadata::subdirectory() const
std::filesystem::path Metadata::subdirectory() const
{
return _subdirectory;
}
@@ -370,7 +370,7 @@ void Metadata::setClassname(const std::string& name)
_classname = name;
}
void Metadata::setSubdirectory(const boost::filesystem::path& path)
void Metadata::setSubdirectory(const std::filesystem::path& path)
{
_subdirectory = path;
}
@@ -475,7 +475,7 @@ void Metadata::removeTag(const std::string& tag)
_tag.erase(new_end, _tag.end());
}
void Metadata::removeFile(const boost::filesystem::path& path)
void Metadata::removeFile(const std::filesystem::path& path)
{
auto new_end = std::remove(_file.begin(), _file.end(), path);
_file.erase(new_end, _file.end());

View File

@@ -25,7 +25,7 @@
#include "FCConfig.h"
#include <boost/filesystem.hpp>
#include <filesystem>
#include <map>
#include <memory>
@@ -67,11 +67,11 @@ struct AppExport Contact
struct AppExport License
{
License() = default;
License(std::string name, boost::filesystem::path file);
License(std::string name, std::filesystem::path file);
explicit License(const XERCES_CPP_NAMESPACE::DOMElement* elem);
std::string
name; //< Short name of license, e.g. "LGPL2", "MIT", "Mozilla Public License", etc.
boost::filesystem::path
std::filesystem::path
file; //< Optional path to the license file, relative to the XML file's location
bool operator==(const License& rhs) const;
};
@@ -205,7 +205,7 @@ public:
* This constructor takes a path to an XML file and loads the XML from that file as
* metadata.
*/
explicit Metadata(const boost::filesystem::path& metadataFile);
explicit Metadata(const std::filesystem::path& metadataFile);
/**
* Construct a Metadata object from a DOM node.
@@ -248,12 +248,12 @@ public:
std::vector<Meta::Dependency>
replace() const; //< Zero or more packages this package is intended to replace.
std::vector<std::string> tag() const; //< Zero or more text tags related to this package.
boost::filesystem::path icon() const; //< Path to an icon file.
std::filesystem::path icon() const; //< Path to an icon file.
std::string
classname() const; //< Recognized for convenience -- generally only used by Workbenches.
boost::filesystem::path
std::filesystem::path
subdirectory() const; //< Optional, override the default subdirectory name for this item.
std::vector<boost::filesystem::path>
std::vector<std::filesystem::path>
file() const; //< Arbitrary files associated with this package or content item.
Meta::Version freecadmin() const; //< The minimum FreeCAD version.
Meta::Version freecadmax() const; //< The maximum FreeCAD version.
@@ -307,10 +307,10 @@ public:
void addConflict(const Meta::Dependency& dep);
void addReplace(const Meta::Dependency& dep);
void addTag(const std::string& tag);
void setIcon(const boost::filesystem::path& path);
void setIcon(const std::filesystem::path& path);
void setClassname(const std::string& name);
void setSubdirectory(const boost::filesystem::path& path);
void addFile(const boost::filesystem::path& path);
void setSubdirectory(const std::filesystem::path& path);
void addFile(const std::filesystem::path& path);
void addContentItem(const std::string& tag, const Metadata& item);
void setFreeCADMin(const Meta::Version& version);
void setFreeCADMax(const Meta::Version& version);
@@ -327,7 +327,7 @@ public:
void removeConflict(const Meta::Dependency& dep);
void removeReplace(const Meta::Dependency& dep);
void removeTag(const std::string& tag);
void removeFile(const boost::filesystem::path& path);
void removeFile(const std::filesystem::path& path);
// Utility functions to clear lists
void clearContent();
@@ -344,7 +344,7 @@ public:
/**
* Write the metadata to an XML file
*/
void write(const boost::filesystem::path& file) const;
void write(const std::filesystem::path& file) const;
/**
* Determine whether this package satisfies the given dependency
@@ -371,10 +371,10 @@ private:
std::vector<Meta::Dependency> _conflict;
std::vector<Meta::Dependency> _replace;
std::vector<std::string> _tag;
boost::filesystem::path _icon;
std::filesystem::path _icon;
std::string _classname;
boost::filesystem::path _subdirectory;
std::vector<boost::filesystem::path> _file;
std::filesystem::path _subdirectory;
std::vector<std::filesystem::path> _file;
Meta::Version _freecadmin;
Meta::Version _freecadmax;
Meta::Version _pythonmin;

View File

@@ -177,7 +177,7 @@ PropertyPath::~PropertyPath() = default;
//**************************************************************************
// Setter/getter for the property
void PropertyPath::setValue(const boost::filesystem::path& Path)
void PropertyPath::setValue(const std::filesystem::path& Path)
{
aboutToSetValue();
_cValue = Path;
@@ -187,15 +187,11 @@ void PropertyPath::setValue(const boost::filesystem::path& Path)
void PropertyPath::setValue(const char* Path)
{
aboutToSetValue();
#if (BOOST_FILESYSTEM_VERSION == 2)
_cValue = boost::filesystem::path(Path, boost::filesystem::no_check);
#else
_cValue = boost::filesystem::path(Path);
#endif
_cValue = std::filesystem::path(Path);
hasSetValue();
}
const boost::filesystem::path& PropertyPath::getValue() const
const std::filesystem::path& PropertyPath::getValue() const
{
return _cValue;
}

View File

@@ -117,7 +117,7 @@ public:
/** Sets the property
*/
void setValue(const boost::filesystem::path&);
void setValue(const std::filesystem::path&);
/** Sets the property
*/
@@ -125,7 +125,7 @@ public:
/** This method returns a string representation of the property
*/
const boost::filesystem::path& getValue() const;
const std::filesystem::path& getValue() const;
const char* getEditorName() const override
{
@@ -153,7 +153,7 @@ public:
}
protected:
boost::filesystem::path _cValue;
std::filesystem::path _cValue;
};
/// Property wrapper around an Enumeration object.

View File

@@ -36,6 +36,7 @@
#include <boost/bimap.hpp>
#include <boost/bimap/set_of.hpp>
#include <boost/bimap/unordered_set_of.hpp>
#include <boost/io/ios_state.hpp>
#include <boost/iostreams/stream.hpp>
#include "MappedElement.h"

View File

@@ -208,18 +208,18 @@ std::string FileInfo::getTempFileName(const char* FileName, const char* Path)
#endif
}
boost::filesystem::path FileInfo::stringToPath(const std::string& str)
std::filesystem::path FileInfo::stringToPath(const std::string& str)
{
#if defined(FC_OS_WIN32)
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
boost::filesystem::path path(converter.from_bytes(str));
std::filesystem::path path(converter.from_bytes(str));
#else
boost::filesystem::path path(str);
std::filesystem::path path(str);
#endif
return path;
}
std::string FileInfo::pathToString(const boost::filesystem::path& path)
std::string FileInfo::pathToString(const std::filesystem::path& path)
{
#if defined(FC_OS_WIN32)
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
@@ -583,14 +583,14 @@ bool FileInfo::createDirectory() const
bool FileInfo::createDirectories() const
{
try {
boost::filesystem::path path(stringToPath(FileName));
if (boost::filesystem::exists(path)) {
std::filesystem::path path(stringToPath(FileName));
if (std::filesystem::exists(path)) {
return true;
}
boost::filesystem::create_directories(path);
std::filesystem::create_directories(path);
return true;
}
catch (const boost::filesystem::filesystem_error&) {
catch (const std::filesystem::filesystem_error&) {
return false;
}
}

View File

@@ -25,7 +25,7 @@
#ifndef BASE_FILEINFO_H
#define BASE_FILEINFO_H
#include <boost/filesystem.hpp>
#include <filesystem>
#include <string>
#include <vector>
#include <Base/TimeInfo.h>
@@ -158,9 +158,9 @@ public:
/// Get the path to the dir which is considered to temp files
static const std::string& getTempPath();
/// Convert from filesystem path to string
static std::string pathToString(const boost::filesystem::path& path);
static std::string pathToString(const std::filesystem::path& path);
/// Convert from string to filesystem path
static boost::filesystem::path stringToPath(const std::string& str);
static std::filesystem::path stringToPath(const std::string& str);
//@}
private:

View File

@@ -25,6 +25,7 @@
#include <algorithm>
#include <array>
#include <cmath>
#include <cstring>
#include <limits>
#include <sstream>
#include <utility>

View File

@@ -48,7 +48,7 @@
#include <Base/Interpreter.h>
#include <CXX/WrapPython.h>
#include <boost/filesystem.hpp>
#include <filesystem>
#include <LibraryVersions.h>
#include <zlib.h>
@@ -60,7 +60,7 @@
using namespace Gui;
using namespace Gui::Dialog;
namespace fs = boost::filesystem;
namespace fs = std::filesystem;
static QString prettyProductInfoWrapper()
{
@@ -548,8 +548,8 @@ void AboutDialog::addModuleInfo(QTextStream& str, const QString& modPath, bool&
str << " * " << (mod.isDir() ? QDir(modPath).dirName() : mod.fileName());
try {
auto metadataFile =
boost::filesystem::path(mod.absoluteFilePath().toStdString()) / "package.xml";
if (boost::filesystem::exists(metadataFile)) {
std::filesystem::path(mod.absoluteFilePath().toStdString()) / "package.xml";
if (std::filesystem::exists(metadataFile)) {
App::Metadata metadata(metadataFile);
if (metadata.version() != App::Meta::Version()) {
str << QLatin1String(" ") + QString::fromStdString(metadata.version().str());

View File

@@ -33,7 +33,7 @@
using namespace Gui::Dialog;
namespace fs = boost::filesystem;
namespace fs = std::filesystem;
/* TRANSLATOR Gui::Dialog::DlgPreferencePackManagementImp */

View File

@@ -26,7 +26,7 @@
#include <memory>
#include <QDialog>
#include <boost/filesystem.hpp>
#include <filesystem>
#include <FCGlobal.h>

View File

@@ -34,7 +34,7 @@
using namespace Gui;
using namespace Gui::Dialog;
namespace fs = boost::filesystem;
namespace fs = std::filesystem;
/* TRANSLATOR Gui::Dialog::DlgRevertToBackupConfigImp */
@@ -71,12 +71,22 @@ void DlgRevertToBackupConfigImp::changeEvent(QEvent *e)
}
}
// FIXME: Replace with more accurate C++20 solution once its usable: https://stackoverflow.com/a/68593141
template <typename TP>
static std::time_t to_time_t(TP tp)
{
using namespace std::chrono;
auto sctp = time_point_cast<system_clock::duration>(tp - TP::clock::now()
+ system_clock::now());
return system_clock::to_time_t(sctp);
}
void DlgRevertToBackupConfigImp::showEvent(QShowEvent* event)
{
ui->listWidget->clear();
const auto& backups = Application::Instance->prefPackManager()->configBackups();
for (const auto& backup : backups) {
auto modification_date = QDateTime::fromSecsSinceEpoch(fs::last_write_time(backup));
auto modification_date = QDateTime::fromSecsSinceEpoch(to_time_t(fs::last_write_time(backup)));
auto item = new QListWidgetItem(QLocale().toString(modification_date));
item->setData(Qt::UserRole, QString::fromStdString(backup.string()));
ui->listWidget->addItem(item);

View File

@@ -29,7 +29,7 @@
# include <mutex>
#endif
#include <boost/filesystem.hpp>
#include <filesystem>
#include <boost/algorithm/string.hpp>
#include <QDir>
@@ -48,15 +48,15 @@
using namespace Gui;
using namespace xercesc;
namespace fs = boost::filesystem;
namespace fs = std::filesystem;
static boost::filesystem::path getSavedPrefPacksPath()
static std::filesystem::path getSavedPrefPacksPath()
{
return fs::path(Base::FileInfo::stringToPath(App::Application::getUserAppDataDir()))
/ "SavedPreferencePacks";
}
static boost::filesystem::path getResourcePrefPacksPath()
static std::filesystem::path getResourcePrefPacksPath()
{
return fs::path(Base::FileInfo::stringToPath(App::Application::getResourceDir())) / "Gui"
/ "PreferencePacks";
@@ -228,29 +228,25 @@ void Gui::PreferencePackManager::AddPackToMetadata(const std::string &packName)
}
void Gui::PreferencePackManager::importConfig(const std::string& packName,
const boost::filesystem::path& path)
const std::filesystem::path& path)
{
AddPackToMetadata(packName);
auto savedPreferencePacksDirectory = getSavedPreferencePacksPath();
auto cfgFilename = savedPreferencePacksDirectory / packName / (packName + ".cfg");
#if BOOST_VERSION >= 107400
fs::copy_file(path, cfgFilename, fs::copy_options::overwrite_existing);
#else
fs::copy_file(path, cfgFilename, fs::copy_option::overwrite_if_exists);
#endif
rescan();
}
// TODO(Shvedov): Is this suitable place for this method? It is more generic,
// and maybe more suitable place at Application?
std::vector<boost::filesystem::path> Gui::PreferencePackManager::modPaths() const
std::vector<std::filesystem::path> Gui::PreferencePackManager::modPaths() const
{
auto userModPath = fs::path(Base::FileInfo::stringToPath(App::Application::getUserAppDataDir())) / "Mod";
auto& config = App::Application::Config();
auto additionalModules = config.find("AdditionalModulePaths");
std::vector<boost::filesystem::path> result;
std::vector<std::filesystem::path> result;
if (additionalModules != config.end()) {
boost::split(result,
@@ -262,12 +258,12 @@ std::vector<boost::filesystem::path> Gui::PreferencePackManager::modPaths() cons
return result;
}
boost::filesystem::path Gui::PreferencePackManager::getSavedPreferencePacksPath() const
std::filesystem::path Gui::PreferencePackManager::getSavedPreferencePacksPath() const
{
return getSavedPrefPacksPath();
}
boost::filesystem::path Gui::PreferencePackManager::getResourcePreferencePacksPath() const
std::filesystem::path Gui::PreferencePackManager::getResourcePreferencePacksPath() const
{
return getResourcePrefPacksPath();
}
@@ -309,7 +305,7 @@ void Gui::PreferencePackManager::FindPreferencePacksInPackage(const fs::path &mo
}
}
void PreferencePackManager::TryFindPreferencePacksInPackage(const boost::filesystem::path& mod)
void PreferencePackManager::TryFindPreferencePacksInPackage(const std::filesystem::path& mod)
{
auto packageMetadataFile = mod / "package.xml";
static const auto modDirectory = fs::path(Base::FileInfo::stringToPath(App::Application::getUserAppDataDir())) / "Mod" / "SavedPreferencePacks";
@@ -625,6 +621,16 @@ void Gui::PreferencePackManager::BackupCurrentConfig() const
App::GetApplication().GetUserParameter().SaveDocument(Base::FileInfo::pathToString(filename).c_str());
}
// FIXME: Replace with more accurate C++20 solution once its usable: https://stackoverflow.com/a/68593141
template <typename TP>
static std::time_t to_time_t(TP tp)
{
using namespace std::chrono;
auto sctp = time_point_cast<system_clock::duration>(tp - TP::clock::now()
+ system_clock::now());
return system_clock::to_time_t(sctp);
}
void Gui::PreferencePackManager::DeleteOldBackups() const
{
constexpr auto oneWeek = 60.0 * 60.0 * 24.0 * 7.0;
@@ -632,7 +638,7 @@ void Gui::PreferencePackManager::DeleteOldBackups() const
auto backupDirectory = getSavedPreferencePacksPath() / "Backups";
if (fs::exists(backupDirectory) && fs::is_directory(backupDirectory)) {
for (const auto& backup : fs::directory_iterator(backupDirectory)) {
if (std::difftime(now, fs::last_write_time(backup)) > oneWeek) {
if (std::difftime(now, to_time_t(fs::last_write_time(backup))) > oneWeek) {
try {
fs::remove(backup);
}
@@ -642,9 +648,10 @@ void Gui::PreferencePackManager::DeleteOldBackups() const
}
}
std::vector<boost::filesystem::path> Gui::PreferencePackManager::configBackups() const
// FIXME: Replace with more accurate C++20 solution once its usable: https://stackoverflow.com/a/68593141
std::vector<std::filesystem::path> Gui::PreferencePackManager::configBackups() const
{
std::vector<boost::filesystem::path> results;
std::vector<std::filesystem::path> results;
auto backupDirectory = getSavedPreferencePacksPath() / "Backups";
if (fs::exists(backupDirectory) && fs::is_directory(backupDirectory)) {
for (const auto& backup : fs::directory_iterator(backupDirectory)) {

View File

@@ -44,7 +44,7 @@ namespace Gui {
* \param path A path to a mod directory that contains a preferencePack
* \param metadata The metadata from the package.xml file describing this preferencePack
*/
PreferencePack(const boost::filesystem::path& path, const App::Metadata& metadata);
PreferencePack(const std::filesystem::path& path, const App::Metadata& metadata);
~PreferencePack() = default;
@@ -68,7 +68,7 @@ namespace Gui {
void applyConfigChanges() const;
boost::filesystem::path _path;
std::filesystem::path _path;
App::Metadata _metadata;
};
@@ -168,7 +168,7 @@ namespace Gui {
struct TemplateFile {
std::string group; // Generally the Add-On/Mod/Package name
std::string name;
boost::filesystem::path path;
std::filesystem::path path;
};
/**
@@ -184,37 +184,37 @@ namespace Gui {
/**
* Get a list of all available config file backups. Backups are currently stored for one week.
*/
std::vector<boost::filesystem::path> configBackups() const;
std::vector<std::filesystem::path> configBackups() const;
/**
* Import an existing config file as a preference pack with a given name.
*/
void importConfig(const std::string &packName, const boost::filesystem::path &path);
void importConfig(const std::string &packName, const std::filesystem::path &path);
/**
* Get a list of all mod directories.
*/
std::vector<boost::filesystem::path> modPaths() const;
std::vector<std::filesystem::path> modPaths() const;
/**
* Get the path to the saved preference packs.
*/
boost::filesystem::path getSavedPreferencePacksPath() const;
std::filesystem::path getSavedPreferencePacksPath() const;
/**
* Get the path to the preference packs of the resource directory.
*/
boost::filesystem::path getResourcePreferencePacksPath() const;
std::filesystem::path getResourcePreferencePacksPath() const;
/**
* Collect all preference packs of a directory.
*/
std::vector<std::string> getPacksFromDirectory(const boost::filesystem::path& path) const;
std::vector<std::string> getPacksFromDirectory(const std::filesystem::path& path) const;
private:
void FindPreferencePacksInPackage(const boost::filesystem::path& mod);
void TryFindPreferencePacksInPackage(const boost::filesystem::path& mod);
void FindPreferencePacksInPackage(const std::filesystem::path& mod);
void TryFindPreferencePacksInPackage(const std::filesystem::path& mod);
void BackupCurrentConfig() const;
@@ -222,7 +222,7 @@ namespace Gui {
void AddPackToMetadata(const std::string &packName) const;
std::vector<boost::filesystem::path> _preferencePackPaths;
std::vector<std::filesystem::path> _preferencePackPaths;
std::vector<TemplateFile> _templateFiles;
std::map<std::string, PreferencePack> _preferencePacks;
mutable std::mutex _mutex;

View File

@@ -62,7 +62,7 @@
using namespace Gui;
using namespace Gui::Dialog;
namespace fs = boost::filesystem;
namespace fs = std::filesystem;
using namespace Base;
/* TRANSLATOR Gui::Dialog::DlgSettingsGeneral */

View File

@@ -25,6 +25,7 @@
#define GUI_WINDOW_H
#include <Base/Parameter.h>
#include <functional>
namespace Gui {

View File

@@ -24,7 +24,7 @@
#include <memory>
#include <boost/filesystem.hpp>
#include <filesystem>
#include <Mod/Material/MaterialGlobal.h>
@@ -34,7 +34,7 @@
#include "MaterialLibrary.h"
#include "MaterialFilter.h"
namespace fs = boost::filesystem;
namespace fs = std::filesystem;
class QMutex;

View File

@@ -187,8 +187,6 @@ class DocumentBasicCases(unittest.TestCase):
self.assertTrue(L1.Float - 47.11 < 0.001)
self.assertTrue(L1.Bool == True)
self.assertTrue(L1.String == "4711")
# temporarily not checked because of strange behavior of boost::filesystem JR
# self.assertTrue(L1.Path == "c:/temp")
self.assertTrue(float(L1.Angle) - 3.0 < 0.001)
self.assertTrue(float(L1.Distance) - 47.11 < 0.001)

View File

@@ -9,11 +9,29 @@
#include "Base/Exception.h"
#include "Base/Reader.h"
#include <array>
#include <boost/filesystem.hpp>
#include <filesystem>
#include <fstream>
#include <random>
#include <string>
#include <xercesc/util/PlatformUtils.hpp>
namespace fs = boost::filesystem;
namespace fs = std::filesystem;
static std::string random_string(size_t length)
{
const std::string digits = "0123456789";
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(0, digits.size() - 1);
std::string result;
for (size_t i = 0; i < length; ++i) {
result += digits[dis(gen)];
}
return result;
}
class ReaderXML
{
@@ -21,7 +39,8 @@ public:
ReaderXML()
{
_tempDir = fs::temp_directory_path();
fs::path filename = fs::unique_path("unit_test_Reader-%%%%.xml");
fs::path filename =
std::string("unit_test_Reader-") + random_string(4) + std::string(".xml");
_tempFile = _tempDir / filename;
}
~ReaderXML()