From 90fe4c5124e3fd335f05804d3cc47ba996e62b14 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 3 Jan 2013 10:16:05 +0100 Subject: TextFile: convert to a class --- src/db/SimpleDatabasePlugin.cxx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/db') diff --git a/src/db/SimpleDatabasePlugin.cxx b/src/db/SimpleDatabasePlugin.cxx index 04e31949..84e4e7ce 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) -- cgit v1.2.3