made user & config save configurable

This commit is contained in:
EntireTwix 2021-06-16 21:40:31 -07:00
parent 9a3a54c4ca
commit e681b4109d
3 changed files with 6 additions and 4 deletions

View file

@ -4,3 +4,5 @@
constexpr unsigned max_log_size = 100;
constexpr unsigned pre_log_size = 10;
constexpr unsigned max_name_size = 50;
constexpr const char *users_location = "../users.json";
constexpr const char *config_location = "../config.json";

View file

@ -73,7 +73,7 @@ int main(int argc, char **argv)
[](const drogon::HttpRequestPtr &req, const drogon::HttpResponsePtr &resp) {
resp->addHeader("Access-Control-Allow-Origin", "*");
});
app().loadConfigFile("../config.json").registerController(API).setThreadNum(std::stoul(argv[3])).run();
app().loadConfigFile(config_location).registerController(API).setThreadNum(std::stoul(argv[3])).run();
return 0;
}

View file

@ -238,7 +238,7 @@ void Bank::Save()
}
else
{
std::ofstream user_save("../users.json");
std::ofstream user_save(users_location);
Json::StreamWriterBuilder builder;
const std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
writer->write(temp, &user_save);
@ -252,7 +252,7 @@ void Bank::Load()
Json::CharReaderBuilder builder;
Json::Value temp;
std::ifstream user_save("../users.json");
std::ifstream user_save(users_location);
builder["collectComments"] = true;
JSONCPP_STRING errs;
if (!parseFromStream(builder, user_save, &temp, &errs))