refactor(Core): replace boost::filesystem with std::filesystem (#6800)

This commit is contained in:
Francesco Borzì
2021-07-09 16:43:51 +02:00
committed by GitHub
parent f79e23e887
commit ebb80145b3
6 changed files with 24 additions and 28 deletions

View File

@@ -8,6 +8,7 @@
#include "Log.h"
#include "Optional.h"
#include "Util.h"
#include <filesystem>
#include <boost/algorithm/string/join.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/process/args.hpp>
@@ -82,7 +83,7 @@ namespace Acore
{
// With binding stdin
return child{
exe = boost::filesystem::absolute(executable).string(),
exe = std::filesystem::absolute(executable).string(),
args = argsVector,
env = environment(boost::this_process::environment()),
std_in = inputFile.get(),
@@ -94,7 +95,7 @@ namespace Acore
{
// Without binding stdin
return child{
exe = boost::filesystem::absolute(executable).string(),
exe = std::filesystem::absolute(executable).string(),
args = argsVector,
env = environment(boost::this_process::environment()),
std_in = boost::process::close,

View File

@@ -13,7 +13,7 @@
#include "QueryResult.h"
#include "StartProcess.h"
#include "UpdateFetcher.h"
#include <boost/filesystem/operations.hpp>
#include <filesystem>
#include <fstream>
#include <iostream>
@@ -27,7 +27,7 @@ std::string DBUpdaterUtil::GetCorrectedMySQLExecutable()
bool DBUpdaterUtil::CheckExecutable()
{
boost::filesystem::path exe(GetCorrectedMySQLExecutable());
std::filesystem::path exe(GetCorrectedMySQLExecutable());
if (!is_regular_file(exe))
{
exe = Acore::SearchExecutableInPath("mysql");
@@ -191,13 +191,13 @@ bool DBUpdater<T>::Create(DatabaseWorkerPool<T>& pool)
catch (UpdateException&)
{
LOG_FATAL("sql.updates", "Failed to create database %s! Does the user (named in *.conf) have `CREATE`, `ALTER`, `DROP`, `INSERT` and `DELETE` privileges on the MySQL server?", pool.GetConnectionInfo()->database.c_str());
boost::filesystem::remove(temp);
std::filesystem::remove(temp);
return false;
}
LOG_INFO("sql.updates", "Done.");
LOG_INFO("sql.updates", " ");
boost::filesystem::remove(temp);
std::filesystem::remove(temp);
return true;
}
@@ -294,7 +294,7 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool)
std::string const DirPathStr = DBUpdater<T>::GetBaseFilesDirectory();
Path const DirPath(DirPathStr);
if (!boost::filesystem::is_directory(DirPath))
if (!std::filesystem::is_directory(DirPath))
{
LOG_ERROR("sql.updates", ">> Directory \"%s\" not exist", DirPath.generic_string().c_str());
return false;
@@ -306,10 +306,10 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool)
return false;
}
boost::filesystem::directory_iterator const DirItr;
std::filesystem::directory_iterator const DirItr;
uint32 FilesCount = 0;
for (boost::filesystem::directory_iterator itr(DirPath); itr != DirItr; ++itr)
for (std::filesystem::directory_iterator itr(DirPath); itr != DirItr; ++itr)
{
if (itr->path().extension() == ".sql")
FilesCount++;
@@ -321,7 +321,7 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool)
return false;
}
for (boost::filesystem::directory_iterator itr(DirPath); itr != DirItr; ++itr)
for (std::filesystem::directory_iterator itr(DirPath); itr != DirItr; ++itr)
{
if (itr->path().extension() != ".sql")
continue;

View File

@@ -9,6 +9,7 @@
#include "DatabaseEnv.h"
#include "Define.h"
#include <string>
#include <filesystem>
template <class T>
class DatabaseWorkerPool;
@@ -54,7 +55,7 @@ template <class T>
class AC_DATABASE_API DBUpdater
{
public:
using Path = boost::filesystem::path;
using Path = std::filesystem::path;
static inline std::string GetConfigEntry();
static inline std::string GetTableName();

View File

@@ -4,7 +4,6 @@
*/
#include "UpdateFetcher.h"
#include "Common.h"
#include "CryptoHash.h"
#include "DBUpdater.h"
#include "Field.h"
@@ -12,11 +11,10 @@
#include "QueryResult.h"
#include "Tokenize.h"
#include "Util.h"
#include <boost/filesystem/operations.hpp>
#include <fstream>
#include <sstream>
#include <fstream>
using namespace boost::filesystem;
using namespace std::filesystem;
struct UpdateFetcher::DirectoryEntry
{

View File

@@ -12,11 +12,7 @@
#include <string>
#include <unordered_map>
#include <vector>
namespace boost::filesystem
{
class path;
}
#include <filesystem>
struct AC_DATABASE_API UpdateResult
{
@@ -33,7 +29,7 @@ struct AC_DATABASE_API UpdateResult
class AC_DATABASE_API UpdateFetcher
{
typedef boost::filesystem::path Path;
typedef std::filesystem::path Path;
public:
UpdateFetcher(Path const& updateDirectory,

View File

@@ -25,7 +25,7 @@ EndScriptData */
#include "StringConvert.h"
#include "VMapFactory.h"
#include "VMapManager2.h"
#include <boost/filesystem/operations.hpp>
#include <filesystem>
#include <boost/version.hpp>
#include <openssl/crypto.h>
#include <openssl/opensslv.h>
@@ -154,20 +154,20 @@ public:
for (std::string const& subDir : subDirs)
{
boost::filesystem::path mapPath(dataDir);
std::filesystem::path mapPath(dataDir);
mapPath /= subDir;
if (!boost::filesystem::exists(mapPath))
if (!std::filesystem::exists(mapPath))
{
handler->PSendSysMessage("%s directory doesn't exist!. Using path: %s", subDir.c_str(), mapPath.generic_string().c_str());
continue;
}
auto end = boost::filesystem::directory_iterator();
std::size_t folderSize = std::accumulate(boost::filesystem::directory_iterator(mapPath), end, std::size_t(0), [](std::size_t val, boost::filesystem::path const& mapFile)
auto end = std::filesystem::directory_iterator();
std::size_t folderSize = std::accumulate(std::filesystem::directory_iterator(mapPath), end, std::size_t(0), [](std::size_t val, std::filesystem::path const& mapFile)
{
if (boost::filesystem::is_regular_file(mapFile))
val += boost::filesystem::file_size(mapFile);
if (std::filesystem::is_regular_file(mapFile))
val += std::filesystem::file_size(mapFile);
return val;
});