[File Paths] Implement Path Manager (#2440)

* Push up branch for testing

* Path manager

* Tweaks

* Changes

* More path work

* Update paths for eqemu_server.pl

* More path work

* Import and export client files

* Path remove

* More path work

* Update eqemu_config.h

* Fix tests

* Tests disable temp

* Update eqemu_config.h

* Update .drone.yml

* Hook tests back up

* Update main.cpp

* Platform tests

* Fix include

* Use std::filesystem on windows

* Fix IPCMutex name on windows

* std::filesystem changes

* Update path_manager.cpp

* Explicit string cast

* Explicit string cast

* Update path_manager.cpp

* Windows fixes

* Mapped files

* Relative fixes

* Use relative paths off of cwd

* Update Debian image to Debian 11 (updates GCC)

Co-authored-by: hg <4683435+hgtw@users.noreply.github.com>
This commit is contained in:
Chris Miles
2022-09-28 04:08:59 -05:00
committed by GitHub
parent 19791195e5
commit f8e7576ae7
53 changed files with 641 additions and 502 deletions
+11 -6
View File
@@ -25,6 +25,7 @@
#include "zoneserver.h"
#include "../common/ip_util.h"
#include "../common/zone_store.h"
#include "../common/path_manager.h"
extern ZSList zoneserver_list;
extern WorldConfig Config;
@@ -169,14 +170,14 @@ int get_file_size(const std::string &filename) // path to file
void WorldBoot::CheckForServerScript(bool force_download)
{
const std::string file = "eqemu_server.pl";
const std::string file = fmt::format("{}/eqemu_server.pl", path.GetServerPath());
std::ifstream f(file);
/* Fetch EQEmu Server script */
if (!f || get_file_size(file) < 100 || force_download) {
if (force_download) {
std::remove("eqemu_server.pl");
std::remove(fmt::format("{}/eqemu_server.pl", path.GetServerPath()).c_str());
} /* Delete local before fetch */
std::cout << "Pulling down EQEmu Server Maintenance Script (eqemu_server.pl)..." << std::endl;
@@ -199,13 +200,15 @@ void WorldBoot::CheckForServerScript(bool force_download)
if (auto res = r.Get(u.get_path().c_str())) {
if (res->status == 200) {
// write file
std::ofstream out("eqemu_server.pl");
std::string script = fmt::format("{}/eqemu_server.pl", path.GetServerPath());
std::ofstream out(script);
out << res->body;
out.close();
#ifdef _WIN32
#else
system("chmod 755 eqemu_server.pl");
system("chmod +x eqemu_server.pl");
system(fmt::format("chmod 755 {}", script).c_str());
system(fmt::format("chmod +x {}", script).c_str());
#endif
}
}
@@ -216,7 +219,8 @@ void WorldBoot::CheckForXMLConfigUpgrade()
{
if (!std::ifstream("eqemu_config.json") && std::ifstream("eqemu_config.xml")) {
CheckForServerScript(true);
if (system("perl eqemu_server.pl convert_xml")) {}
std::string command = fmt::format("perl {}/eqemu_server.pl convert_xml", path.GetServerPath());
if (system(command.c_str())) {}
}
else {
CheckForServerScript();
@@ -291,6 +295,7 @@ bool WorldBoot::DatabaseLoadRoutines(int argc, char **argv)
// logging system init
auto logging = LogSys.SetDatabase(&database)
->SetLogPath(path.GetLogPath())
->LoadLogDatabaseSettings();
if (RuleB(Logging, WorldGMSayLogging)) {