From 3a84512486181d97690b755d87b04eb683c671c7 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 4 Apr 2023 15:27:36 -0500 Subject: [PATCH] half-assed work --- src/engine/config.cpp | 8 ++++++++ src/ta-utils.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/engine/config.cpp b/src/engine/config.cpp index 2feb8a82..916c1a4b 100644 --- a/src/engine/config.cpp +++ b/src/engine/config.cpp @@ -24,20 +24,24 @@ #include bool DivConfig::save(const char* path) { + logD("opening config for write: %s",path); FILE* f=ps_fopen(path,"wb"); if (f==NULL) { logW("could not write config file! %s",strerror(errno)); + reportError(fmt::sprintf("could not write config file! %s",strerror(errno))); return false; } for (auto& i: conf) { String toWrite=fmt::sprintf("%s=%s\n",i.first,i.second); if (fwrite(toWrite.c_str(),1,toWrite.size(),f)!=toWrite.size()) { logW("could not write config file! %s",strerror(errno)); + reportError(fmt::sprintf("could not write config file! %s",strerror(errno))); fclose(f); return false; } } fclose(f); + logD("config file written successfully."); return true; } @@ -81,12 +85,16 @@ void DivConfig::parseLine(const char* line) { bool DivConfig::loadFromFile(const char* path, bool createOnFail) { char line[4096]; + logD("opening config for read: %s",path); FILE* f=ps_fopen(path,"rb"); if (f==NULL) { + logD("config does not exist"); if (createOnFail) { logI("creating default config."); + showWarning(fmt::sprintf("Creating default config: %s",strerror(errno)); return save(path); } else { + showWarning(fmt::sprintf("COULD NOT LOAD CONFIG %s",strerror(errno)); return false; } } diff --git a/src/ta-utils.h b/src/ta-utils.h index f0c896d0..0b81cc85 100644 --- a/src/ta-utils.h +++ b/src/ta-utils.h @@ -66,4 +66,6 @@ struct TAParam { func(f) {} }; +void reportError(String what); + #endif