diff options
Diffstat (limited to '')
-rw-r--r-- | src/PlaylistDatabase.cxx (renamed from src/playlist_database.c) | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/playlist_database.c b/src/PlaylistDatabase.cxx index 6b9d87155..edc6a2815 100644 --- a/src/playlist_database.c +++ b/src/PlaylistDatabase.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -18,10 +18,13 @@ */ #include "config.h" -#include "playlist_database.h" -#include "playlist_vector.h" -#include "text_file.h" +#include "PlaylistDatabase.hxx" +#include "PlaylistVector.hxx" +#include "TextFile.hxx" + +extern "C" { #include "string_util.h" +} #include <string.h> #include <stdlib.h> @@ -33,27 +36,25 @@ playlist_database_quark(void) } void -playlist_vector_save(FILE *fp, const struct list_head *pv) +playlist_vector_save(FILE *fp, const PlaylistVector &pv) { - struct playlist_metadata *pm; - playlist_vector_for_each(pm, pv) + for (const PlaylistInfo &pi : pv) fprintf(fp, PLAYLIST_META_BEGIN "%s\n" "mtime: %li\n" "playlist_end\n", - pm->name, (long)pm->mtime); + pi.name.c_str(), (long)pi.mtime); } bool -playlist_metadata_load(FILE *fp, struct list_head *pv, const char *name, - GString *buffer, GError **error_r) +playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name, + GError **error_r) { - struct playlist_metadata pm = { - .mtime = 0, - }; + PlaylistInfo pm(name, 0); + char *line, *colon; const char *value; - while ((line = read_text_line(fp, buffer)) != NULL && + while ((line = file.ReadLine()) != NULL && strcmp(line, "playlist_end") != 0) { colon = strchr(line, ':'); if (colon == NULL || colon == line) { @@ -74,6 +75,6 @@ playlist_metadata_load(FILE *fp, struct list_head *pv, const char *name, } } - playlist_vector_update_or_add(pv, name, pm.mtime); + pv.UpdateOrInsert(std::move(pm)); return true; } |