aboutsummaryrefslogtreecommitdiffstats
path: root/src/SongUpdate.cxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/SongUpdate.cxx38
1 files changed, 14 insertions, 24 deletions
diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx
index 1a873fedc..cba3c6957 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);
@@ -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;
}