From cccbcf510a44aec0ce6a956cc1c7c96e6cfa94f3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 23 Feb 2016 10:30:06 +0100 Subject: [PATCH] tag/{Id3,Ape}: remove Path overloads --- src/tag/ApeLoader.cxx | 18 ------------------ src/tag/ApeLoader.hxx | 10 ---------- src/tag/ApeReplayGain.cxx | 20 -------------------- src/tag/ApeReplayGain.hxx | 4 ---- src/tag/ApeTag.cxx | 18 ------------------ src/tag/ApeTag.hxx | 10 ---------- src/tag/Id3Load.cxx | 18 ------------------ src/tag/Id3Load.hxx | 10 ---------- src/tag/TagId3.cxx | 24 ------------------------ src/tag/TagId3.hxx | 15 --------------- test/ReadApeTags.cxx | 19 ++++++++++++++++++- test/dump_rva2.cxx | 23 ++++++++++++++++------- 12 files changed, 34 insertions(+), 155 deletions(-) diff --git a/src/tag/ApeLoader.cxx b/src/tag/ApeLoader.cxx index 652017525..f3f2ce49a 100644 --- a/src/tag/ApeLoader.cxx +++ b/src/tag/ApeLoader.cxx @@ -20,11 +20,7 @@ #include "config.h" #include "ApeLoader.hxx" #include "system/ByteOrder.hxx" -#include "fs/Path.hxx" -#include "thread/Mutex.hxx" -#include "thread/Cond.hxx" #include "input/InputStream.hxx" -#include "input/LocalOpen.hxx" #include "util/StringView.hxx" #include "util/Error.hxx" @@ -108,17 +104,3 @@ tag_ape_scan(InputStream &is, ApeTagCallback callback) return true; } - -bool -tag_ape_scan(Path path_fs, ApeTagCallback callback) -{ - Mutex mutex; - Cond cond; - - std::unique_ptr is(OpenLocalInputStream(path_fs, mutex, - cond, IgnoreError())); - if (!is) - return false; - - return tag_ape_scan(*is, callback); -} diff --git a/src/tag/ApeLoader.hxx b/src/tag/ApeLoader.hxx index 0e2eadff1..322e38d33 100644 --- a/src/tag/ApeLoader.hxx +++ b/src/tag/ApeLoader.hxx @@ -42,14 +42,4 @@ typedef std::function -#include static bool replay_gain_ape_callback(unsigned long flags, const char *key, @@ -63,20 +60,3 @@ replay_gain_ape_read(InputStream &is, ReplayGainInfo &info) return tag_ape_scan(is, callback) && found; } - -bool -replay_gain_ape_read(Path path_fs, ReplayGainInfo &info) -{ - bool found = false; - - auto callback = [&info, &found] - (unsigned long flags, const char *key, - StringView value) { - found |= replay_gain_ape_callback(flags, key, - value, - info); - return true; - }; - - return tag_ape_scan(path_fs, callback) && found; -} diff --git a/src/tag/ApeReplayGain.hxx b/src/tag/ApeReplayGain.hxx index 0150aae3b..1df4d6708 100644 --- a/src/tag/ApeReplayGain.hxx +++ b/src/tag/ApeReplayGain.hxx @@ -23,13 +23,9 @@ #include "check.h" class InputStream; -class Path; struct ReplayGainInfo; bool replay_gain_ape_read(InputStream &is, ReplayGainInfo &info); -bool -replay_gain_ape_read(Path path_fs, ReplayGainInfo &info); - #endif diff --git a/src/tag/ApeTag.cxx b/src/tag/ApeTag.cxx index a045cb7b6..7fb65c5fc 100644 --- a/src/tag/ApeTag.cxx +++ b/src/tag/ApeTag.cxx @@ -23,7 +23,6 @@ #include "Tag.hxx" #include "TagTable.hxx" #include "TagHandler.hxx" -#include "fs/Path.hxx" #include "util/StringView.hxx" #include @@ -121,20 +120,3 @@ tag_ape_scan2(InputStream &is, return tag_ape_scan(is, callback) && recognized; } - -bool -tag_ape_scan2(Path path_fs, - const TagHandler &handler, void *handler_ctx) -{ - bool recognized = false; - - auto callback = [handler, handler_ctx, &recognized] - (unsigned long flags, const char *key, - StringView value) { - recognized |= tag_ape_import_item(flags, key, value, - handler, handler_ctx); - return true; - }; - - return tag_ape_scan(path_fs, callback) && recognized; -} diff --git a/src/tag/ApeTag.hxx b/src/tag/ApeTag.hxx index a90715fe3..e2bf3db62 100644 --- a/src/tag/ApeTag.hxx +++ b/src/tag/ApeTag.hxx @@ -22,7 +22,6 @@ #include "TagTable.hxx" -class Path; class InputStream; struct TagHandler; @@ -37,13 +36,4 @@ bool tag_ape_scan2(InputStream &is, const TagHandler &handler, void *handler_ctx); -/** - * Scan the APE tags of a file. - * - * @param path_fs the path of the file in filesystem encoding - */ -bool -tag_ape_scan2(Path path_fs, - const TagHandler &handler, void *handler_ctx); - #endif diff --git a/src/tag/Id3Load.cxx b/src/tag/Id3Load.cxx index cdb1066ea..79c87184f 100644 --- a/src/tag/Id3Load.cxx +++ b/src/tag/Id3Load.cxx @@ -24,11 +24,7 @@ #include "Log.hxx" #include "Riff.hxx" #include "Aiff.hxx" -#include "fs/Path.hxx" -#include "thread/Mutex.hxx" -#include "thread/Cond.hxx" #include "input/InputStream.hxx" -#include "input/LocalOpen.hxx" #include @@ -225,17 +221,3 @@ tag_id3_load(InputStream &is) return tag; } - -UniqueId3Tag -tag_id3_load(Path path_fs, Error &error) -{ - Mutex mutex; - Cond cond; - - std::unique_ptr is(OpenLocalInputStream(path_fs, mutex, - cond, error)); - if (!is) - return nullptr; - - return tag_id3_load(*is); -} diff --git a/src/tag/Id3Load.hxx b/src/tag/Id3Load.hxx index fa59654bb..70af2bd73 100644 --- a/src/tag/Id3Load.hxx +++ b/src/tag/Id3Load.hxx @@ -23,7 +23,6 @@ #include "check.h" #include "Id3Unique.hxx" -class Path; class Error; class InputStream; @@ -36,13 +35,4 @@ class InputStream; UniqueId3Tag tag_id3_load(InputStream &is); -/** - * Loads the ID3 tags from the file into a libid3tag object. - * - * @return nullptr on error or if no ID3 tag was found in the file (no - * Error will be set) - */ -UniqueId3Tag -tag_id3_load(Path path_fs, Error &error); - #endif diff --git a/src/tag/TagId3.cxx b/src/tag/TagId3.cxx index 14d109391..9bf0eb8c4 100644 --- a/src/tag/TagId3.cxx +++ b/src/tag/TagId3.cxx @@ -359,27 +359,3 @@ tag_id3_scan(InputStream &is, scan_id3_tag(tag.get(), handler, handler_ctx); return true; } - -bool -tag_id3_scan(Path path_fs, - const TagHandler &handler, void *handler_ctx) -{ - UniqueId3Tag tag; - - try { - Error error; - tag = tag_id3_load(path_fs, error); - if (tag == nullptr) { - if (error.IsDefined()) - LogError(error); - - return false; - } - } catch (const std::runtime_error &e) { - LogError(e); - return false; - } - - scan_id3_tag(tag.get(), handler, handler_ctx); - return true; -} diff --git a/src/tag/TagId3.hxx b/src/tag/TagId3.hxx index b1146efe2..f47f77c4a 100644 --- a/src/tag/TagId3.hxx +++ b/src/tag/TagId3.hxx @@ -24,7 +24,6 @@ #include "Compiler.h" class InputStream; -class Path; struct TagHandler; struct Tag; struct id3_tag; @@ -35,10 +34,6 @@ bool tag_id3_scan(InputStream &is, const TagHandler &handler, void *handler_ctx); -bool -tag_id3_scan(Path path_fs, - const TagHandler &handler, void *handler_ctx); - Tag * tag_id3_import(id3_tag *); @@ -52,8 +47,6 @@ scan_id3_tag(id3_tag *tag, #else -#include "fs/Path.hxx" - static inline bool tag_id3_scan(gcc_unused InputStream &is, gcc_unused const TagHandler &handler, @@ -62,14 +55,6 @@ tag_id3_scan(gcc_unused InputStream &is, return false; } -static inline bool -tag_id3_scan(gcc_unused Path path_fs, - gcc_unused const TagHandler &handler, - gcc_unused void *handler_ctx) -{ - return false; -} - #endif #endif diff --git a/test/ReadApeTags.cxx b/test/ReadApeTags.cxx index a0a0e652e..3619dd0c3 100644 --- a/test/ReadApeTags.cxx +++ b/test/ReadApeTags.cxx @@ -19,8 +19,14 @@ #include "config.h" #include "tag/ApeLoader.hxx" +#include "thread/Mutex.hxx" +#include "thread/Cond.hxx" #include "fs/Path.hxx" +#include "Log.hxx" +#include "input/InputStream.hxx" +#include "input/LocalOpen.hxx" #include "util/StringView.hxx" +#include "util/Error.hxx" #include #include @@ -55,7 +61,18 @@ main(int argc, char **argv) } const Path path = Path::FromFS(argv[1]); - if (!tag_ape_scan(path, MyApeTagCallback)) { + + Mutex mutex; + Cond cond; + + Error error; + auto is = OpenLocalInputStream(path, mutex, cond, error); + if (!is) { + LogError(error); + return EXIT_FAILURE; + } + + if (!tag_ape_scan(*is, MyApeTagCallback)) { fprintf(stderr, "error\n"); return EXIT_FAILURE; } diff --git a/test/dump_rva2.cxx b/test/dump_rva2.cxx index e486f7b3f..d009549fa 100644 --- a/test/dump_rva2.cxx +++ b/test/dump_rva2.cxx @@ -22,8 +22,12 @@ #include "tag/TagRva2.hxx" #include "ReplayGainInfo.hxx" #include "config/ConfigGlobal.hxx" +#include "thread/Mutex.hxx" +#include "thread/Cond.hxx" #include "util/Error.hxx" #include "fs/Path.hxx" +#include "input/InputStream.hxx" +#include "input/LocalOpen.hxx" #include "Log.hxx" #include @@ -54,16 +58,21 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - const char *path = argv[1]; + const Path path = Path::FromFS(argv[1]); + + Mutex mutex; + Cond cond; Error error; - const auto tag = tag_id3_load(Path::FromFS(path), error); - if (tag == NULL) { - if (error.IsDefined()) - LogError(error); - else - fprintf(stderr, "No ID3 tag found\n"); + auto is = OpenLocalInputStream(path, mutex, cond, error); + if (!is) { + LogError(error); + return EXIT_FAILURE; + } + const auto tag = tag_id3_load(*is); + if (tag == NULL) { + fprintf(stderr, "No ID3 tag found\n"); return EXIT_FAILURE; }