aboutsummaryrefslogtreecommitdiff
path: root/src/Main.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-14 11:00:22 +0100
committerMax Kellermann <max@duempel.org>2013-01-14 11:00:22 +0100
commit92fb0e829a9b61d1b1db4bdbe6096c1772b7c819 (patch)
tree5445042f3932b283bb07e31d1d8c020ee5858581 /src/Main.cxx
parent43a99285378bb5d40ed311729ff1f507fbe37a34 (diff)
StateFile: convert to a class
Diffstat (limited to 'src/Main.cxx')
-rw-r--r--src/Main.cxx22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/Main.cxx b/src/Main.cxx
index f9062ccc..e0083bff 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -101,6 +101,8 @@ EventLoop *main_loop;
Partition *global_partition;
+static StateFile *state_file;
+
static bool
glue_daemonize_init(const struct options *options, GError **error_r)
{
@@ -225,14 +227,18 @@ glue_state_file_init(GError **error_r)
GError *error = NULL;
char *path = config_dup_path(CONF_STATE_FILE, &error);
- if (path == NULL && error != NULL) {
- g_propagate_error(error_r, error);
- return false;
+ if (path == nullptr) {
+ if (error != nullptr) {
+ g_propagate_error(error_r, error);
+ return false;
+ }
+
+ return true;
}
- state_file_init(path, *global_partition);
+ state_file = new StateFile(path, *global_partition, *main_loop);
g_free(path);
-
+ state_file->Read();
return true;
}
@@ -519,7 +525,11 @@ int mpd_main(int argc, char *argv[])
mpd_inotify_finish();
#endif
- state_file_finish(*global_partition);
+ if (state_file != nullptr) {
+ state_file->Write();
+ delete state_file;
+ }
+
pc_kill(&global_partition->pc);
finishZeroconf();
client_manager_deinit();