decoder/sidplay: use config_param::GetBlockPath()
This commit is contained in:
parent
c013026821
commit
a547d2aaba
@ -25,7 +25,9 @@
|
|||||||
#include "fs/AllocatedPath.hxx"
|
#include "fs/AllocatedPath.hxx"
|
||||||
#include "util/FormatString.hxx"
|
#include "util/FormatString.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
|
#include "util/Error.hxx"
|
||||||
#include "system/ByteOrder.hxx"
|
#include "system/ByteOrder.hxx"
|
||||||
|
#include "system/FatalError.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -49,16 +51,16 @@ static unsigned default_songlength;
|
|||||||
static bool filter_setting;
|
static bool filter_setting;
|
||||||
|
|
||||||
static GKeyFile *
|
static GKeyFile *
|
||||||
sidplay_load_songlength_db(const char *path)
|
sidplay_load_songlength_db(const Path path)
|
||||||
{
|
{
|
||||||
GError *error = nullptr;
|
GError *error = nullptr;
|
||||||
gchar *data;
|
gchar *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
if (!g_file_get_contents(path, &data, &size, &error)) {
|
if (!g_file_get_contents(path.c_str(), &data, &size, &error)) {
|
||||||
FormatError(sidplay_domain,
|
FormatError(sidplay_domain,
|
||||||
"unable to read songlengths file %s: %s",
|
"unable to read songlengths file %s: %s",
|
||||||
path, error->message);
|
path.c_str(), error->message);
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -75,7 +77,7 @@ sidplay_load_songlength_db(const char *path)
|
|||||||
if (!success) {
|
if (!success) {
|
||||||
FormatError(sidplay_domain,
|
FormatError(sidplay_domain,
|
||||||
"unable to parse songlengths file %s: %s",
|
"unable to parse songlengths file %s: %s",
|
||||||
path, error->message);
|
path.c_str(), error->message);
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
g_key_file_free(db);
|
g_key_file_free(db);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -89,9 +91,12 @@ static bool
|
|||||||
sidplay_init(const config_param ¶m)
|
sidplay_init(const config_param ¶m)
|
||||||
{
|
{
|
||||||
/* read the songlengths database file */
|
/* read the songlengths database file */
|
||||||
const char *songlength_file = param.GetBlockValue("songlength_database");
|
Error error;
|
||||||
if (songlength_file != nullptr)
|
const auto database_path = param.GetBlockPath("songlength_database", error);
|
||||||
songlength_database = sidplay_load_songlength_db(songlength_file);
|
if (!database_path.IsNull())
|
||||||
|
songlength_database = sidplay_load_songlength_db(database_path);
|
||||||
|
else if (error.IsDefined())
|
||||||
|
FatalError(error);
|
||||||
|
|
||||||
default_songlength = param.GetBlockValue("default_songlength", 0u);
|
default_songlength = param.GetBlockValue("default_songlength", 0u);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user