Main: move code to TryReadConfigFile()
This commit is contained in:
parent
6229210d51
commit
7778210269
22
src/Main.cxx
22
src/Main.cxx
@ -590,16 +590,26 @@ MainConfigured(const CommandLineOptions &options,
|
|||||||
|
|
||||||
#ifdef ANDROID
|
#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
|
static void
|
||||||
LoadConfigFile(JNIEnv *env, ConfigData &config)
|
LoadConfigFile(JNIEnv *env, ConfigData &config)
|
||||||
{
|
{
|
||||||
if (const auto dir = Environment::getExternalStorageDirectory(env);
|
if (const auto dir = Environment::getExternalStorageDirectory(env);
|
||||||
!dir.IsNull()) {
|
!dir.IsNull())
|
||||||
const auto config_path =
|
TryReadConfigFile(config, dir / Path::FromFS("mpd.conf"));
|
||||||
dir / Path::FromFS("mpd.conf");
|
|
||||||
if (FileExists(config_path))
|
|
||||||
ReadConfigFile(config, config_path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user