refactor(Core): replace boost::filesystem with std::filesystem (#6800)
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Optional.h"
|
#include "Optional.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
#include <filesystem>
|
||||||
#include <boost/algorithm/string/join.hpp>
|
#include <boost/algorithm/string/join.hpp>
|
||||||
#include <boost/iostreams/copy.hpp>
|
#include <boost/iostreams/copy.hpp>
|
||||||
#include <boost/process/args.hpp>
|
#include <boost/process/args.hpp>
|
||||||
@@ -82,7 +83,7 @@ namespace Acore
|
|||||||
{
|
{
|
||||||
// With binding stdin
|
// With binding stdin
|
||||||
return child{
|
return child{
|
||||||
exe = boost::filesystem::absolute(executable).string(),
|
exe = std::filesystem::absolute(executable).string(),
|
||||||
args = argsVector,
|
args = argsVector,
|
||||||
env = environment(boost::this_process::environment()),
|
env = environment(boost::this_process::environment()),
|
||||||
std_in = inputFile.get(),
|
std_in = inputFile.get(),
|
||||||
@@ -94,7 +95,7 @@ namespace Acore
|
|||||||
{
|
{
|
||||||
// Without binding stdin
|
// Without binding stdin
|
||||||
return child{
|
return child{
|
||||||
exe = boost::filesystem::absolute(executable).string(),
|
exe = std::filesystem::absolute(executable).string(),
|
||||||
args = argsVector,
|
args = argsVector,
|
||||||
env = environment(boost::this_process::environment()),
|
env = environment(boost::this_process::environment()),
|
||||||
std_in = boost::process::close,
|
std_in = boost::process::close,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include "QueryResult.h"
|
#include "QueryResult.h"
|
||||||
#include "StartProcess.h"
|
#include "StartProcess.h"
|
||||||
#include "UpdateFetcher.h"
|
#include "UpdateFetcher.h"
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ std::string DBUpdaterUtil::GetCorrectedMySQLExecutable()
|
|||||||
|
|
||||||
bool DBUpdaterUtil::CheckExecutable()
|
bool DBUpdaterUtil::CheckExecutable()
|
||||||
{
|
{
|
||||||
boost::filesystem::path exe(GetCorrectedMySQLExecutable());
|
std::filesystem::path exe(GetCorrectedMySQLExecutable());
|
||||||
if (!is_regular_file(exe))
|
if (!is_regular_file(exe))
|
||||||
{
|
{
|
||||||
exe = Acore::SearchExecutableInPath("mysql");
|
exe = Acore::SearchExecutableInPath("mysql");
|
||||||
@@ -191,13 +191,13 @@ bool DBUpdater<T>::Create(DatabaseWorkerPool<T>& pool)
|
|||||||
catch (UpdateException&)
|
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());
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("sql.updates", "Done.");
|
LOG_INFO("sql.updates", "Done.");
|
||||||
LOG_INFO("sql.updates", " ");
|
LOG_INFO("sql.updates", " ");
|
||||||
boost::filesystem::remove(temp);
|
std::filesystem::remove(temp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,7 +294,7 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool)
|
|||||||
std::string const DirPathStr = DBUpdater<T>::GetBaseFilesDirectory();
|
std::string const DirPathStr = DBUpdater<T>::GetBaseFilesDirectory();
|
||||||
|
|
||||||
Path const DirPath(DirPathStr);
|
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());
|
LOG_ERROR("sql.updates", ">> Directory \"%s\" not exist", DirPath.generic_string().c_str());
|
||||||
return false;
|
return false;
|
||||||
@@ -306,10 +306,10 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::directory_iterator const DirItr;
|
std::filesystem::directory_iterator const DirItr;
|
||||||
uint32 FilesCount = 0;
|
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")
|
if (itr->path().extension() == ".sql")
|
||||||
FilesCount++;
|
FilesCount++;
|
||||||
@@ -321,7 +321,7 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool)
|
|||||||
return false;
|
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")
|
if (itr->path().extension() != ".sql")
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "DatabaseEnv.h"
|
#include "DatabaseEnv.h"
|
||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class DatabaseWorkerPool;
|
class DatabaseWorkerPool;
|
||||||
@@ -54,7 +55,7 @@ template <class T>
|
|||||||
class AC_DATABASE_API DBUpdater
|
class AC_DATABASE_API DBUpdater
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Path = boost::filesystem::path;
|
using Path = std::filesystem::path;
|
||||||
|
|
||||||
static inline std::string GetConfigEntry();
|
static inline std::string GetConfigEntry();
|
||||||
static inline std::string GetTableName();
|
static inline std::string GetTableName();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UpdateFetcher.h"
|
#include "UpdateFetcher.h"
|
||||||
#include "Common.h"
|
|
||||||
#include "CryptoHash.h"
|
#include "CryptoHash.h"
|
||||||
#include "DBUpdater.h"
|
#include "DBUpdater.h"
|
||||||
#include "Field.h"
|
#include "Field.h"
|
||||||
@@ -12,11 +11,10 @@
|
|||||||
#include "QueryResult.h"
|
#include "QueryResult.h"
|
||||||
#include "Tokenize.h"
|
#include "Tokenize.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <fstream>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
|
|
||||||
struct UpdateFetcher::DirectoryEntry
|
struct UpdateFetcher::DirectoryEntry
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,11 +12,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <filesystem>
|
||||||
namespace boost::filesystem
|
|
||||||
{
|
|
||||||
class path;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct AC_DATABASE_API UpdateResult
|
struct AC_DATABASE_API UpdateResult
|
||||||
{
|
{
|
||||||
@@ -33,7 +29,7 @@ struct AC_DATABASE_API UpdateResult
|
|||||||
|
|
||||||
class AC_DATABASE_API UpdateFetcher
|
class AC_DATABASE_API UpdateFetcher
|
||||||
{
|
{
|
||||||
typedef boost::filesystem::path Path;
|
typedef std::filesystem::path Path;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UpdateFetcher(Path const& updateDirectory,
|
UpdateFetcher(Path const& updateDirectory,
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ EndScriptData */
|
|||||||
#include "StringConvert.h"
|
#include "StringConvert.h"
|
||||||
#include "VMapFactory.h"
|
#include "VMapFactory.h"
|
||||||
#include "VMapManager2.h"
|
#include "VMapManager2.h"
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <filesystem>
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
#include <openssl/crypto.h>
|
#include <openssl/crypto.h>
|
||||||
#include <openssl/opensslv.h>
|
#include <openssl/opensslv.h>
|
||||||
@@ -154,20 +154,20 @@ public:
|
|||||||
|
|
||||||
for (std::string const& subDir : subDirs)
|
for (std::string const& subDir : subDirs)
|
||||||
{
|
{
|
||||||
boost::filesystem::path mapPath(dataDir);
|
std::filesystem::path mapPath(dataDir);
|
||||||
mapPath /= subDir;
|
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());
|
handler->PSendSysMessage("%s directory doesn't exist!. Using path: %s", subDir.c_str(), mapPath.generic_string().c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto end = boost::filesystem::directory_iterator();
|
auto end = std::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)
|
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))
|
if (std::filesystem::is_regular_file(mapFile))
|
||||||
val += boost::filesystem::file_size(mapFile);
|
val += std::filesystem::file_size(mapFile);
|
||||||
return val;
|
return val;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user