diff options
Diffstat (limited to '')
-rw-r--r-- | src/SongUpdate.cxx | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx index 1a873fedc..fe78e1e0f 100644 --- a/src/SongUpdate.cxx +++ b/src/SongUpdate.cxx @@ -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); @@ -95,7 +90,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,7 +100,7 @@ Song::UpdateFile() mtime = st.st_mtime; delete tag; - tag = tag_builder.Commit(); + tag = tag_builder.CommitNew(); return true; } @@ -113,7 +108,6 @@ bool Song::UpdateFileInArchive() { const char *suffix; - const struct DecoderPlugin *plugin; assert(IsFile()); @@ -123,16 +117,32 @@ Song::UpdateFileInArchive() if (suffix == nullptr) return false; - plugin = decoder_plugin_from_suffix(suffix, nullptr); - if (plugin == nullptr) + if (!decoder_plugins_supports_suffix(suffix)) + return false; + + const auto path_fs = map_song_fs(*this); + if (path_fs.IsNull()) + return false; + + 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; +} - //accept every file that has music suffix - //because we don't support tag reading through - //input streams - tag = new Tag(); +bool +Song::UpdateStream() +{ + assert(!IsFile()); + TagBuilder tag_builder; + if (!tag_stream_scan(uri, full_tag_handler, &tag_builder)) + return false; + + delete tag; + tag = tag_builder.CommitNew(); return true; } |