params: specify path using PARAMS_ROOT (#28257)

* Add PARAMS_ROOT env var

* Change getenv type signature

* Use getenv default_val
This commit is contained in:
Kacper Rączy 2023-05-23 19:02:22 +02:00 committed by GitHub
parent 3785e161f0
commit b43a875ba2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -189,7 +189,7 @@ bool create_directories(const std::string& dir, mode_t mode) {
return createDirectory(dir, mode); return createDirectory(dir, mode);
} }
std::string getenv(const char* key, const char* default_val) { std::string getenv(const char* key, std::string default_val) {
const char* val = ::getenv(key); const char* val = ::getenv(key);
return val ? val : default_val; return val ? val : default_val;
} }

View File

@ -70,7 +70,7 @@ std::string string_format(const std::string& format, Args... args) {
return std::string(buf.get(), buf.get() + size - 1); return std::string(buf.get(), buf.get() + size - 1);
} }
std::string getenv(const char* key, const char* default_val = ""); std::string getenv(const char* key, std::string default_val = "");
int getenv(const char* key, int default_val); int getenv(const char* key, int default_val);
float getenv(const char* key, float default_val); float getenv(const char* key, float default_val);

View File

@ -19,7 +19,7 @@ inline std::string log_root() {
return Hardware::PC() ? util::getenv("HOME") + "/.comma/media/0/realdata" : "/data/media/0/realdata"; return Hardware::PC() ? util::getenv("HOME") + "/.comma/media/0/realdata" : "/data/media/0/realdata";
} }
inline std::string params() { inline std::string params() {
return Hardware::PC() ? util::getenv("HOME") + "/.comma/params" : "/data/params"; return Hardware::PC() ? util::getenv("PARAMS_ROOT", util::getenv("HOME") + "/.comma/params") : "/data/params";
} }
inline std::string rsa_file() { inline std::string rsa_file() {
return Hardware::PC() ? util::getenv("HOME") + "/.comma/persist/comma/id_rsa" : "/persist/comma/id_rsa"; return Hardware::PC() ? util::getenv("HOME") + "/.comma/persist/comma/id_rsa" : "/persist/comma/id_rsa";