From e5039c478aa93e3e107ee9031a3cf27a6c203fea Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 17 Jan 2013 00:56:57 +0100 Subject: Path: new class "Path" wraps filesystem path strings --- src/db/SimpleDatabasePlugin.cxx | 5 +++-- src/db/SimpleDatabasePlugin.hxx | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/db') diff --git a/src/db/SimpleDatabasePlugin.cxx b/src/db/SimpleDatabasePlugin.cxx index 8eea81e30..b7c60d9d8 100644 --- a/src/db/SimpleDatabasePlugin.cxx +++ b/src/db/SimpleDatabasePlugin.cxx @@ -68,7 +68,7 @@ SimpleDatabase::Configure(const struct config_param *param, GError **error_r) return false; } - path = _path; + path = Path::FromUTF8(_path); free(_path); return true; @@ -77,6 +77,7 @@ SimpleDatabase::Configure(const struct config_param *param, GError **error_r) bool SimpleDatabase::Check(GError **error_r) const { + assert(!path.IsNull()); assert(!path.empty()); /* Check if the file exists */ @@ -153,7 +154,7 @@ SimpleDatabase::Load(GError **error_r) assert(!path.empty()); assert(root != NULL); - TextFile file(path.c_str()); + TextFile file(path); if (file.HasFailed()) { g_set_error(error_r, simple_db_quark(), errno, "Failed to open database file \"%s\": %s", diff --git a/src/db/SimpleDatabasePlugin.hxx b/src/db/SimpleDatabasePlugin.hxx index 789dcdae9..3549aa98c 100644 --- a/src/db/SimpleDatabasePlugin.hxx +++ b/src/db/SimpleDatabasePlugin.hxx @@ -21,17 +21,17 @@ #define MPD_SIMPLE_DATABASE_PLUGIN_HXX #include "DatabasePlugin.hxx" +#include "Path.hxx" #include "gcc.h" #include -#include #include struct Directory; class SimpleDatabase : public Database { - std::string path; + Path path; Directory *root; @@ -41,6 +41,9 @@ class SimpleDatabase : public Database { unsigned borrowed_song_count; #endif + SimpleDatabase() + :path(Path::Null()) {} + public: gcc_pure Directory *GetRoot() { -- cgit v1.2.3