TextFile: convert to a class

This commit is contained in:
Max Kellermann
2013-01-03 10:16:05 +01:00
parent 2452447c81
commit 90fe4c5124
17 changed files with 97 additions and 98 deletions

View File

@@ -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)