diff options
Diffstat (limited to 'src/db/plugins/simple/DirectorySave.cxx')
-rw-r--r-- | src/db/plugins/simple/DirectorySave.cxx | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/db/plugins/simple/DirectorySave.cxx b/src/db/plugins/simple/DirectorySave.cxx index 923ee2b82..868507c67 100644 --- a/src/db/plugins/simple/DirectorySave.cxx +++ b/src/db/plugins/simple/DirectorySave.cxx @@ -107,12 +107,11 @@ directory_save(BufferedOutputStream &os, const Directory &directory) static bool ParseLine(Directory &directory, const char *line) { - if (StringStartsWith(line, DIRECTORY_MTIME)) { - directory.mtime = - ParseUint64(line + sizeof(DIRECTORY_MTIME) - 1); - } else if (StringStartsWith(line, DIRECTORY_TYPE)) { - directory.device = - ParseTypeString(line + sizeof(DIRECTORY_TYPE) - 1); + const char *p; + if ((p = StringAfterPrefix(line, DIRECTORY_MTIME))) { + directory.mtime = ParseUint64(p); + } else if ((p = StringAfterPrefix(line, DIRECTORY_TYPE))) { + directory.device = ParseTypeString(p); } else return false; @@ -168,15 +167,15 @@ directory_load(TextFile &file, Directory &directory, Error &error) while ((line = file.ReadLine()) != nullptr && !StringStartsWith(line, DIRECTORY_END)) { - if (StringStartsWith(line, DIRECTORY_DIR)) { + const char *p; + if ((p = StringAfterPrefix(line, DIRECTORY_DIR))) { Directory *subdir = directory_load_subdir(file, directory, - line + sizeof(DIRECTORY_DIR) - 1, - error); + p, error); if (subdir == nullptr) return false; - } else if (StringStartsWith(line, SONG_BEGIN)) { - const char *name = line + sizeof(SONG_BEGIN) - 1; + } else if ((p = StringAfterPrefix(line, SONG_BEGIN))) { + const char *name = p; if (directory.FindSong(name) != nullptr) { error.Format(directory_domain, @@ -191,8 +190,8 @@ directory_load(TextFile &file, Directory &directory, Error &error) directory.AddSong(Song::NewFrom(std::move(*song), directory)); delete song; - } else if (StringStartsWith(line, PLAYLIST_META_BEGIN)) { - const char *name = line + sizeof(PLAYLIST_META_BEGIN) - 1; + } else if ((p = StringAfterPrefix(line, PLAYLIST_META_BEGIN))) { + const char *name = p; if (!playlist_metadata_load(file, directory.playlists, name, error)) return false; |