diff options
author | Max Kellermann <max@duempel.org> | 2013-01-03 10:16:05 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-03 10:16:05 +0100 |
commit | 90fe4c5124e3fd335f05804d3cc47ba996e62b14 (patch) | |
tree | ef7fb6b3cb2edbe4898431db611f04fb281129fc /src/db/SimpleDatabasePlugin.cxx | |
parent | 2452447c814048ed72e95a459c76b4be65962b5c (diff) | |
download | mpd-90fe4c5124e3fd335f05804d3cc47ba996e62b14.tar.gz mpd-90fe4c5124e3fd335f05804d3cc47ba996e62b14.tar.xz mpd-90fe4c5124e3fd335f05804d3cc47ba996e62b14.zip |
TextFile: convert to a class
Diffstat (limited to 'src/db/SimpleDatabasePlugin.cxx')
-rw-r--r-- | src/db/SimpleDatabasePlugin.cxx | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/db/SimpleDatabasePlugin.cxx b/src/db/SimpleDatabasePlugin.cxx index 04e319498..84e4e7cee 100644 --- a/src/db/SimpleDatabasePlugin.cxx +++ b/src/db/SimpleDatabasePlugin.cxx @@ -26,6 +26,7 @@ #include "DatabaseSave.hxx" #include "DatabaseLock.hxx" #include "db_error.h" +#include "TextFile.hxx" extern "C" { #include "conf.h" @@ -155,20 +156,16 @@ SimpleDatabase::Load(GError **error_r) assert(!path.empty()); assert(root != NULL); - FILE *fp = fopen(path.c_str(), "r"); - if (fp == NULL) { + TextFile file(path.c_str()); + if (file.HasFailed()) { g_set_error(error_r, simple_db_quark(), errno, "Failed to open database file \"%s\": %s", path.c_str(), g_strerror(errno)); return false; } - if (!db_load_internal(fp, root, error_r)) { - fclose(fp); + if (!db_load_internal(file, root, error_r)) return false; - } - - fclose(fp); struct stat st; if (stat(path.c_str(), &st) == 0) |