check in SRSLTE_CONFIG_DIR for configs by default

master
Andre Puschmann 7 years ago
parent 105d93fd5e
commit fb77cb87ca

@ -35,16 +35,15 @@ bool config_exists(std::string &filename, std::string default_name)
{ {
std::ifstream conf(filename.c_str(), std::ios::in); std::ifstream conf(filename.c_str(), std::ios::in);
if(conf.fail()) { if(conf.fail()) {
const char *homedir = NULL; const char *config_dir = NULL;
char full_path[256]; char full_path[256];
ZERO_OBJECT(full_path); ZERO_OBJECT(full_path);
if ((homedir = getenv("HOME")) == NULL) { if ((config_dir = getenv("SRSLTE_CONFIG_DIR")) == NULL) {
homedir = getpwuid(getuid())->pw_dir; fprintf(stderr, "No environment variable SRSLTE_CONFIG_DIR defined.\n"
} "Please run \"export SRSLTE_CONFIG_DIR=/usr/etc/srs\" to define it.\n\n");
if (!homedir) { return false;
homedir = ".";
} }
snprintf(full_path, sizeof(full_path), "%s/.srs/%s", homedir, default_name.c_str()); snprintf(full_path, sizeof(full_path), "%s/%s", config_dir, default_name.c_str());
filename = std::string(full_path); filename = std::string(full_path);
// try to open again // try to open again

Loading…
Cancel
Save