tag/{Id3,Ape}: remove Path overloads
This commit is contained in:
parent
a1e680fec7
commit
cccbcf510a
|
@ -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<InputStream> is(OpenLocalInputStream(path_fs, mutex,
|
||||
cond, IgnoreError()));
|
||||
if (!is)
|
||||
return false;
|
||||
|
||||
return tag_ape_scan(*is, callback);
|
||||
}
|
||||
|
|
|
@ -42,14 +42,4 @@ typedef std::function<bool(unsigned long flags, const char *key,
|
|||
bool
|
||||
tag_ape_scan(InputStream &is, ApeTagCallback callback);
|
||||
|
||||
/**
|
||||
* Scans the APE tag values from a file.
|
||||
*
|
||||
* @param path_fs the path of the file in filesystem encoding
|
||||
* @return false if the file could not be opened or if no APE tag is
|
||||
* present
|
||||
*/
|
||||
bool
|
||||
tag_ape_scan(Path path_fs, ApeTagCallback callback);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,12 +21,9 @@
|
|||
#include "ApeReplayGain.hxx"
|
||||
#include "ApeLoader.hxx"
|
||||
#include "ReplayGain.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "util/ASCII.hxx"
|
||||
#include "util/StringView.hxx"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "Tag.hxx"
|
||||
#include "TagTable.hxx"
|
||||
#include "TagHandler.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "util/StringView.hxx"
|
||||
|
||||
#include <string>
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <id3tag.h>
|
||||
|
||||
|
@ -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<InputStream> is(OpenLocalInputStream(path_fs, mutex,
|
||||
cond, error));
|
||||
if (!is)
|
||||
return nullptr;
|
||||
|
||||
return tag_id3_load(*is);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 <id3tag.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue