Added config_file_path to config

This commit is contained in:
Matt Hill
2015-10-17 08:54:09 -04:00
parent c4a896d969
commit 06cc808560
2 changed files with 12 additions and 12 deletions

View File

@@ -43,53 +43,51 @@ namespace alpr
this->loaded = false; this->loaded = false;
string configFile;
char* envConfigFile; char* envConfigFile;
envConfigFile = getenv (ENV_VARIABLE_CONFIG_FILE); envConfigFile = getenv (ENV_VARIABLE_CONFIG_FILE);
if (config_file.compare("") != 0) if (config_file.compare("") != 0)
{ {
// User has supplied a config file. Use that. // User has supplied a config file. Use that.
configFile = config_file; config_file_path = config_file;
debug_message = "Config file location provided via API"; debug_message = "Config file location provided via API";
} }
else if (envConfigFile != NULL) else if (envConfigFile != NULL)
{ {
// Environment variable is non-empty. Use that. // Environment variable is non-empty. Use that.
configFile = envConfigFile; config_file_path = envConfigFile;
debug_message = "Config file location provided via environment variable: " + string(ENV_VARIABLE_CONFIG_FILE); debug_message = "Config file location provided via environment variable: " + string(ENV_VARIABLE_CONFIG_FILE);
} }
else if (DirectoryExists(getExeDir().c_str()) && fileExists((getExeDir() + CONFIG_FILE).c_str())) else if (DirectoryExists(getExeDir().c_str()) && fileExists((getExeDir() + CONFIG_FILE).c_str()))
{ {
configFile = getExeDir() + CONFIG_FILE; config_file_path = getExeDir() + CONFIG_FILE;
debug_message = "Config file location provided via exe location"; debug_message = "Config file location provided via exe location";
} }
else else
{ {
// Use the default // Use the default
configFile = DEFAULT_CONFIG_FILE; config_file_path = DEFAULT_CONFIG_FILE;
debug_message = "Config file location provided via default location"; debug_message = "Config file location provided via default location";
} }
//string configFile = (this->runtimeBaseDir + CONFIG_FILE);
if (fileExists(configFile.c_str()) == false) if (fileExists(config_file_path.c_str()) == false)
{ {
std::cerr << "--(!) Config file '" << configFile << "' does not exist!" << endl; std::cerr << "--(!) Config file '" << config_file_path << "' does not exist!" << endl;
std::cerr << "--(!) You can specify the configuration file location via the command line " << endl; std::cerr << "--(!) You can specify the configuration file location via the command line " << endl;
std::cerr << "--(!) or by setting the environment variable '" << ENV_VARIABLE_CONFIG_FILE << "'" << endl; std::cerr << "--(!) or by setting the environment variable '" << ENV_VARIABLE_CONFIG_FILE << "'" << endl;
return; return;
} }
else if (DirectoryExists(configFile.c_str())) else if (DirectoryExists(config_file_path.c_str()))
{ {
std::cerr << "--(!) Config file '" << configFile << "' was specified as a directory, rather than a file!" << endl; std::cerr << "--(!) Config file '" << config_file_path << "' was specified as a directory, rather than a file!" << endl;
std::cerr << "--(!) Please specify the full path to the 'openalpr.conf file'" << endl; std::cerr << "--(!) Please specify the full path to the 'openalpr.conf file'" << endl;
std::cerr << "--(!) e.g., /etc/openalpr/openalpr.conf" << endl; std::cerr << "--(!) e.g., /etc/openalpr/openalpr.conf" << endl;
return; return;
} }
loadCommonValues(configFile); loadCommonValues(config_file_path);
if (runtime_dir.compare("") != 0) if (runtime_dir.compare("") != 0)
{ {
@@ -108,7 +106,7 @@ namespace alpr
if (DirectoryExists(this->runtimeBaseDir.c_str()) == false) if (DirectoryExists(this->runtimeBaseDir.c_str()) == false)
{ {
std::cerr << "--(!) Runtime directory '" << this->runtimeBaseDir << "' does not exist!" << endl; std::cerr << "--(!) Runtime directory '" << this->runtimeBaseDir << "' does not exist!" << endl;
std::cerr << "--(!) Please update the OpenALPR config file: '" << configFile << "'" << endl; std::cerr << "--(!) Please update the OpenALPR config file: '" << config_file_path << "'" << endl;
std::cerr << "--(!) to point to the correct location of your runtime_dir" << endl; std::cerr << "--(!) to point to the correct location of your runtime_dir" << endl;
return; return;
} }

View File

@@ -42,6 +42,8 @@ namespace alpr
bool loaded; bool loaded;
std::string config_file_path;
std::string country; std::string country;
int detector; int detector;