mirror of https://github.com/PentHertz/srsLTE.git
try to load config files from /etc/srslte before checking users's home
This commit is contained in:
parent
59435c2c34
commit
c88cc35fdf
|
@ -35,22 +35,32 @@ bool config_exists(std::string &filename, std::string default_name)
|
|||
{
|
||||
std::ifstream conf(filename.c_str(), std::ios::in);
|
||||
if(conf.fail()) {
|
||||
const char *homedir = NULL;
|
||||
// try to find file in /etc/srslte
|
||||
char full_path[256];
|
||||
ZERO_OBJECT(full_path);
|
||||
if ((homedir = getenv("HOME")) == NULL) {
|
||||
homedir = getpwuid(getuid())->pw_dir;
|
||||
}
|
||||
if (!homedir) {
|
||||
homedir = ".";
|
||||
}
|
||||
snprintf(full_path, sizeof(full_path), "%s/.srs/%s", homedir, default_name.c_str());
|
||||
snprintf(full_path, sizeof(full_path), "/etc/srslte/%s", default_name.c_str());
|
||||
filename = std::string(full_path);
|
||||
|
||||
// try to open again
|
||||
conf.open(filename.c_str());
|
||||
if (conf.fail()) {
|
||||
return false;
|
||||
// try home folder
|
||||
const char* homedir = NULL;
|
||||
ZERO_OBJECT(full_path);
|
||||
if ((homedir = getenv("HOME")) == NULL) {
|
||||
homedir = getpwuid(getuid())->pw_dir;
|
||||
}
|
||||
if (!homedir) {
|
||||
homedir = ".";
|
||||
}
|
||||
snprintf(full_path, sizeof(full_path), "%s/.srs/%s", homedir, default_name.c_str());
|
||||
filename = std::string(full_path);
|
||||
|
||||
// try to open again
|
||||
conf.open(filename.c_str());
|
||||
if (conf.fail()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue