From 747acb6d968eb077fe2fb801f4935049178c3743 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 25 Mar 2016 09:12:05 -0400 Subject: [PATCH] Allow main config file to be missing, as long as default is available --- src/openalpr/config.cpp | 2 +- src/openalpr/config_helper.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/openalpr/config.cpp b/src/openalpr/config.cpp index 14d368e..628f89b 100644 --- a/src/openalpr/config.cpp +++ b/src/openalpr/config.cpp @@ -66,7 +66,7 @@ namespace alpr } - if (fileExists(config_file_path.c_str()) == false) + if (fileExists(config_file_path.c_str()) == false && fileExists(CONFIG_FILE_TEMPLATE_LOCATION) == false) { 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; diff --git a/src/openalpr/config_helper.cpp b/src/openalpr/config_helper.cpp index 5310d75..ae1ff17 100644 --- a/src/openalpr/config_helper.cpp +++ b/src/openalpr/config_helper.cpp @@ -113,7 +113,7 @@ namespace alpr int getInt(CSimpleIniA* ini, CSimpleIniA* defaultIni, std::string section, std::string key, int defaultValue) { - if (hasValue(ini, section, key)) + if (ini != NULL && hasValue(ini, section, key)) return getInt(ini, section, key, defaultValue); if (defaultIni != NULL && hasValue(defaultIni, section, key)) @@ -125,7 +125,7 @@ namespace alpr } float getFloat(CSimpleIniA* ini, CSimpleIniA* defaultIni, std::string section, std::string key, float defaultValue) { - if (hasValue(ini, section, key)) + if (ini != NULL && hasValue(ini, section, key)) return getFloat(ini, section, key, defaultValue); if (defaultIni != NULL && hasValue(defaultIni, section, key)) @@ -137,7 +137,7 @@ namespace alpr } std::string getString(CSimpleIniA* ini, CSimpleIniA* defaultIni, std::string section, std::string key, std::string defaultValue) { - if (hasValue(ini, section, key)) + if (ini != NULL && hasValue(ini, section, key)) return getString(ini, section, key, defaultValue); if (defaultIni != NULL && hasValue(defaultIni, section, key)) @@ -148,7 +148,7 @@ namespace alpr } bool getBoolean(CSimpleIniA* ini, CSimpleIniA* defaultIni, std::string section, std::string key, bool defaultValue) { - if (hasValue(ini, section, key)) + if (ini != NULL && hasValue(ini, section, key)) return getBoolean(ini, section, key, defaultValue); if (defaultIni != NULL && hasValue(defaultIni, section, key))