2023-03-06 14:42:04 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
// Copyright The Music Player Daemon Project
|
2018-07-17 23:27:50 +02:00
|
|
|
|
|
|
|
#include "StateFileConfig.hxx"
|
|
|
|
#include "config/Data.hxx"
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
2023-03-06 20:06:41 +01:00
|
|
|
#include "fs/glue/StandardDirectory.hxx"
|
2018-07-17 23:27:50 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
StateFileConfig::StateFileConfig(const ConfigData &config)
|
|
|
|
:path(config.GetPath(ConfigOption::STATE_FILE)),
|
|
|
|
interval(config.GetUnsigned(ConfigOption::STATE_FILE_INTERVAL,
|
2018-07-17 23:34:45 +02:00
|
|
|
DEFAULT_INTERVAL)),
|
|
|
|
restore_paused(config.GetBool(ConfigOption::RESTORE_PAUSED, false))
|
2018-07-17 23:27:50 +02:00
|
|
|
{
|
|
|
|
#ifdef ANDROID
|
|
|
|
if (path.IsNull()) {
|
2022-11-28 13:54:03 +01:00
|
|
|
const auto cache_dir = GetAppCacheDir();
|
2018-07-17 23:27:50 +02:00
|
|
|
if (cache_dir.IsNull())
|
|
|
|
return;
|
|
|
|
|
|
|
|
path = cache_dir / Path::FromFS("state");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|