From 7778210269efc6957d42a588f89eeb68bae91357 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 18 Aug 2022 17:59:01 +0200 Subject: [PATCH] Main: move code to TryReadConfigFile() --- src/Main.cxx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Main.cxx b/src/Main.cxx index 895a96d2c..e764baed3 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -590,16 +590,26 @@ MainConfigured(const CommandLineOptions &options, #ifdef ANDROID +/** + * Wrapper for ReadConfigFile() which returns false if the file was + * not found. + */ +static bool +TryReadConfigFile(ConfigData &config, Path path) +{ + if (!FileExists(path)) + return false; + + ReadConfigFile(config, path); + return true; +} + static void LoadConfigFile(JNIEnv *env, ConfigData &config) { if (const auto dir = Environment::getExternalStorageDirectory(env); - !dir.IsNull()) { - const auto config_path = - dir / Path::FromFS("mpd.conf"); - if (FileExists(config_path)) - ReadConfigFile(config, config_path); - } + !dir.IsNull()) + TryReadConfigFile(config, dir / Path::FromFS("mpd.conf")); } static void