aboutsummaryrefslogtreecommitdiffstats
path: root/src/DirectorySave.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/DirectorySave.cxx')
-rw-r--r--src/DirectorySave.cxx32
1 files changed, 11 insertions, 21 deletions
diff --git a/src/DirectorySave.cxx b/src/DirectorySave.cxx
index fa330d126..709184289 100644
--- a/src/DirectorySave.cxx
+++ b/src/DirectorySave.cxx
@@ -23,15 +23,13 @@
#include "Song.hxx"
#include "SongSave.hxx"
#include "PlaylistDatabase.hxx"
-#include "TextFile.hxx"
+#include "fs/TextFile.hxx"
+#include "util/StringUtil.hxx"
#include "util/NumberParser.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
-#include <glib.h>
-
-#include <assert.h>
-#include <string.h>
+#include <stddef.h>
#define DIRECTORY_DIR "directory: "
#define DIRECTORY_MTIME "mtime: "
@@ -91,7 +89,7 @@ directory_load_subdir(TextFile &file, Directory &parent, const char *name,
return nullptr;
}
- if (g_str_has_prefix(line, DIRECTORY_MTIME)) {
+ if (StringStartsWith(line, DIRECTORY_MTIME)) {
directory->mtime =
ParseUint64(line + sizeof(DIRECTORY_MTIME) - 1);
@@ -103,7 +101,7 @@ directory_load_subdir(TextFile &file, Directory &parent, const char *name,
}
}
- if (!g_str_has_prefix(line, DIRECTORY_BEGIN)) {
+ if (!StringStartsWith(line, DIRECTORY_BEGIN)) {
error.Format(directory_domain, "Malformed line: %s", line);
directory->Delete();
return nullptr;
@@ -124,15 +122,15 @@ directory_load(TextFile &file, Directory &directory, Error &error)
const char *line;
while ((line = file.ReadLine()) != nullptr &&
- !g_str_has_prefix(line, DIRECTORY_END)) {
- if (g_str_has_prefix(line, DIRECTORY_DIR)) {
+ !StringStartsWith(line, DIRECTORY_END)) {
+ if (StringStartsWith(line, DIRECTORY_DIR)) {
Directory *subdir =
directory_load_subdir(file, directory,
line + sizeof(DIRECTORY_DIR) - 1,
error);
if (subdir == nullptr)
return false;
- } else if (g_str_has_prefix(line, SONG_BEGIN)) {
+ } else if (StringStartsWith(line, SONG_BEGIN)) {
const char *name = line + sizeof(SONG_BEGIN) - 1;
Song *song;
@@ -147,19 +145,11 @@ directory_load(TextFile &file, Directory &directory, Error &error)
return false;
directory.AddSong(song);
- } else if (g_str_has_prefix(line, PLAYLIST_META_BEGIN)) {
- /* duplicate the name, because
- playlist_metadata_load() will overwrite the
- buffer */
- char *name = g_strdup(line + sizeof(PLAYLIST_META_BEGIN) - 1);
-
+ } else if (StringStartsWith(line, PLAYLIST_META_BEGIN)) {
+ const char *name = line + sizeof(PLAYLIST_META_BEGIN) - 1;
if (!playlist_metadata_load(file, directory.playlists,
- name, error)) {
- g_free(name);
+ name, error))
return false;
- }
-
- g_free(name);
} else {
error.Format(directory_domain,
"Malformed line: %s", line);