Main: move code to LoadConfigFile()

This commit is contained in:
Max Kellermann 2022-08-18 14:59:50 +02:00
parent 5d0d5b5d97
commit 6229210d51
1 changed files with 13 additions and 7 deletions

View File

@ -590,19 +590,25 @@ MainConfigured(const CommandLineOptions &options,
#ifdef ANDROID
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);
}
}
static void
AndroidMain(JNIEnv *env)
{
CommandLineOptions options;
ConfigData raw_config;
const auto sdcard = Environment::getExternalStorageDirectory(env);
if (!sdcard.IsNull()) {
const auto config_path =
sdcard / Path::FromFS("mpd.conf");
if (FileExists(config_path))
ReadConfigFile(raw_config, config_path);
}
LoadConfigFile(env, raw_config);
MainConfigured(options, raw_config);
}