diff options
author | Sadie Powell <sadie@witchery.services> | 2024-03-19 15:10:25 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-03-19 15:11:40 +0000 |
commit | fde3438ef29447f41a6eb48049f8d620c1c2eb30 (patch) | |
tree | fcd2f03a9d5b693106ab545d3ffd08934149aee2 /modules | |
parent | 1575dea5b96e7249d94ebc9214a73d123919c4ba (diff) |
Allow using absolute paths in more places.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/database/db_atheme.cpp | 2 | ||||
-rw-r--r-- | modules/database/db_flatfile.cpp | 16 | ||||
-rw-r--r-- | modules/database/db_old.cpp | 2 | ||||
-rw-r--r-- | modules/extra/sqlite.cpp | 3 | ||||
-rw-r--r-- | modules/operserv/os_logsearch.cpp | 2 | ||||
-rw-r--r-- | modules/webcpanel/webcpanel.cpp | 2 |
6 files changed, 13 insertions, 14 deletions
diff --git a/modules/database/db_atheme.cpp b/modules/database/db_atheme.cpp index ca53e955b..60870f7a7 100644 --- a/modules/database/db_atheme.cpp +++ b/modules/database/db_atheme.cpp @@ -1290,7 +1290,7 @@ public: EventReturn OnLoadDatabase() override { - const auto dbname = Anope::DataDir + "/" + Config->GetModule(this)->Get<const Anope::string>("database", "atheme.db"); + const auto dbname = Anope::ExpandData(Config->GetModule(this)->Get<const Anope::string>("database", "atheme.db")); std::ifstream fd(dbname.str()); if (!fd.is_open()) { diff --git a/modules/database/db_flatfile.cpp b/modules/database/db_flatfile.cpp index 63c18f744..471c5fc00 100644 --- a/modules/database/db_flatfile.cpp +++ b/modules/database/db_flatfile.cpp @@ -130,8 +130,8 @@ class DBFlatFile final for (const auto &db : dbs) { - const Anope::string &oldname = Anope::DataDir + "/" + db; - Anope::string newname = Anope::DataDir + "/backups/" + db + "-" + Anope::ToString(tm->tm_year + 1900) + Anope::printf("-%02i-", tm->tm_mon + 1) + Anope::printf("%02i", tm->tm_mday); + const auto oldname = Anope::ExpandData(db); + const auto newname = Anope::ExpandData("backups/" + db + "-" + Anope::ToString(tm->tm_year + 1900) + Anope::printf("-%02i-", tm->tm_mon + 1) + Anope::printf("%02i", tm->tm_mday)); /* Backup already exists or no database to backup */ if (Anope::IsFile(newname) || !Anope::IsFile(oldname)) @@ -216,7 +216,7 @@ public: { std::set<Anope::string> tried_dbs; - const Anope::string &db_name = Anope::DataDir + "/" + Config->GetModule(this)->Get<const Anope::string>("database", "anope.db"); + const auto db_name = Anope::ExpandData(Config->GetModule(this)->Get<const Anope::string>("database", "anope.db")); std::fstream fd(db_name.c_str(), std::ios_base::in | std::ios_base::binary); if (!fd.is_open()) @@ -296,9 +296,9 @@ public: Anope::string db_name; if (s_type->GetOwner()) - db_name = Anope::DataDir + "/module_" + s_type->GetOwner()->name + ".db"; + db_name = Anope::ExpandData("module_" + s_type->GetOwner()->name + ".db"); else - db_name = Anope::DataDir + "/" + Config->GetModule(this)->Get<const Anope::string>("database", "anope.db"); + db_name = Anope::ExpandData(Config->GetModule(this)->Get<const Anope::string>("database", "anope.db")); std::fstream *fs = databases[s_type->GetOwner()] = new std::fstream((db_name + ".tmp").c_str(), std::ios_base::out | std::ios_base::trunc | std::ios_base::binary); @@ -325,7 +325,7 @@ public: for (auto &[mod, f] : databases) { - const Anope::string &db_name = Anope::DataDir + "/" + (mod ? (mod->name + ".db") : Config->GetModule(this)->Get<const Anope::string>("database", "anope.db")); + const auto db_name = Anope::ExpandData((mod ? (mod->name + ".db") : Config->GetModule(this)->Get<const Anope::string>("database", "anope.db"))); if (!f->is_open() || !f->good()) { @@ -367,9 +367,9 @@ public: Anope::string db_name; if (stype->GetOwner()) - db_name = Anope::DataDir + "/module_" + stype->GetOwner()->name + ".db"; + db_name = Anope::ExpandData("module_" + stype->GetOwner()->name + ".db"); else - db_name = Anope::DataDir + "/" + Config->GetModule(this)->Get<const Anope::string>("database", "anope.db"); + db_name = Anope::ExpandData(Config->GetModule(this)->Get<const Anope::string>("database", "anope.db")); std::fstream fd(db_name.c_str(), std::ios_base::in | std::ios_base::binary); if (!fd.is_open()) diff --git a/modules/database/db_old.cpp b/modules/database/db_old.cpp index 1cb4a699a..ba861938d 100644 --- a/modules/database/db_old.cpp +++ b/modules/database/db_old.cpp @@ -321,7 +321,7 @@ static dbFILE *open_db_read(const char *service, const char *filename, int versi int myversion; f = new dbFILE; - strscpy(f->filename, (Anope::DataDir + "/" + filename).c_str(), sizeof(f->filename)); + strscpy(f->filename, Anope::ExpandData(filename).c_str(), sizeof(f->filename)); f->mode = 'r'; fp = fopen(f->filename, "rb"); if (!fp) diff --git a/modules/extra/sqlite.cpp b/modules/extra/sqlite.cpp index 4968e8e0d..2454c838c 100644 --- a/modules/extra/sqlite.cpp +++ b/modules/extra/sqlite.cpp @@ -118,8 +118,7 @@ public: if (this->SQLiteServices.find(connname) == this->SQLiteServices.end()) { - Anope::string database = Anope::DataDir + "/" + block->Get<const Anope::string>("database", "anope"); - + auto database = Anope::ExpandData(block->Get<const Anope::string>("database", "anope")); try { auto *ss = new SQLiteService(this, connname, database); diff --git a/modules/operserv/os_logsearch.cpp b/modules/operserv/os_logsearch.cpp index 0282644b2..cd85241e7 100644 --- a/modules/operserv/os_logsearch.cpp +++ b/modules/operserv/os_logsearch.cpp @@ -24,7 +24,7 @@ class CommandOSLogSearch final strftime(timestamp, sizeof(timestamp), "%Y%m%d", tm); - return Anope::LogDir + "/" + file + "." + timestamp; + return Anope::ExpandLog(file + "." + timestamp); } public: diff --git a/modules/webcpanel/webcpanel.cpp b/modules/webcpanel/webcpanel.cpp index 97ca439e4..0ff4beb1a 100644 --- a/modules/webcpanel/webcpanel.cpp +++ b/modules/webcpanel/webcpanel.cpp @@ -61,7 +61,7 @@ public: Configuration::Block *block = Config->GetModule(this); provider_name = block->Get<const Anope::string>("server", "httpd/main"); template_name = block->Get<const Anope::string>("template", "default"); - template_base = Anope::DataDir + "/modules/webcpanel/templates/" + template_name; + template_base = Anope::ExpandData("modules/webcpanel/templates/" + template_name); page_title = block->Get<const Anope::string>("title", "Anope IRC Services"); provider = ServiceReference<HTTPProvider>("HTTPProvider", provider_name); |