diff options
Diffstat (limited to 'src/SongUpdate.cxx')
-rw-r--r-- | src/SongUpdate.cxx | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx index 1a873fedc..70a05bf2a 100644 --- a/src/SongUpdate.cxx +++ b/src/SongUpdate.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -20,14 +20,11 @@ #include "config.h" /* must be first for large file support */ #include "Song.hxx" #include "util/UriUtil.hxx" -#include "util/Error.hxx" #include "Directory.hxx" #include "Mapper.hxx" #include "fs/AllocatedPath.hxx" #include "fs/Traits.hxx" #include "fs/FileSystem.hxx" -#include "InputStream.hxx" -#include "DecoderPlugin.hxx" #include "DecoderList.hxx" #include "tag/Tag.hxx" #include "tag/TagBuilder.hxx" @@ -35,13 +32,11 @@ #include "tag/TagId3.hxx" #include "tag/ApeTag.hxx" #include "TagFile.hxx" -#include "thread/Cond.hxx" +#include "TagStream.hxx" #include <assert.h> #include <string.h> -#include <sys/types.h> #include <sys/stat.h> -#include <stdio.h> Song * Song::LoadFile(const char *path_utf8, Directory *parent) @@ -49,7 +44,7 @@ Song::LoadFile(const char *path_utf8, Directory *parent) Song *song; bool ret; - assert((parent == nullptr) == PathTraits::IsAbsoluteUTF8(path_utf8)); + assert((parent == nullptr) == PathTraitsUTF8::IsAbsolute(path_utf8)); assert(!uri_has_scheme(path_utf8)); assert(strchr(path_utf8, '\n') == nullptr); @@ -83,8 +78,6 @@ tag_scan_fallback(Path path, bool Song::UpdateFile() { - assert(IsFile()); - const auto path_fs = map_song_fs(*this); if (path_fs.IsNull()) return false; @@ -95,7 +88,7 @@ Song::UpdateFile() TagBuilder tag_builder; if (!tag_file_scan(path_fs, - &full_tag_handler, &tag_builder)) + full_tag_handler, &tag_builder)) return false; if (tag_builder.IsEmpty()) @@ -105,34 +98,31 @@ Song::UpdateFile() mtime = st.st_mtime; delete tag; - tag = tag_builder.Commit(); + tag = tag_builder.CommitNew(); return true; } bool Song::UpdateFileInArchive() { - const char *suffix; - const struct DecoderPlugin *plugin; - - assert(IsFile()); - /* check if there's a suffix and a plugin */ - suffix = uri_get_suffix(uri); + const char *suffix = uri_get_suffix(uri); if (suffix == nullptr) return false; - plugin = decoder_plugin_from_suffix(suffix, nullptr); - if (plugin == nullptr) + if (!decoder_plugins_supports_suffix(suffix)) return false; - delete tag; + const auto path_fs = map_song_fs(*this); + if (path_fs.IsNull()) + return false; - //accept every file that has music suffix - //because we don't support tag reading through - //input streams - tag = new Tag(); + TagBuilder tag_builder; + if (!tag_stream_scan(path_fs.c_str(), full_tag_handler, &tag_builder)) + return false; + delete tag; + tag = tag_builder.CommitNew(); return true; } |