diff options
Diffstat (limited to '')
-rw-r--r-- | src/DecoderThread.cxx | 2 | ||||
-rw-r--r-- | src/SongUpdate.cxx | 6 | ||||
-rw-r--r-- | src/TagFile.cxx | 12 | ||||
-rw-r--r-- | src/TagFile.hxx | 3 | ||||
-rw-r--r-- | src/command/FileCommands.cxx | 2 | ||||
-rw-r--r-- | src/playlist/EmbeddedCuePlaylistPlugin.cxx | 11 | ||||
-rw-r--r-- | src/tag/ApeLoader.cxx | 7 | ||||
-rw-r--r-- | src/tag/ApeLoader.hxx | 4 | ||||
-rw-r--r-- | src/tag/ApeReplayGain.cxx | 3 | ||||
-rw-r--r-- | src/tag/ApeReplayGain.hxx | 3 | ||||
-rw-r--r-- | src/tag/ApeTag.cxx | 3 | ||||
-rw-r--r-- | src/tag/ApeTag.hxx | 3 | ||||
-rw-r--r-- | src/tag/TagId3.cxx | 8 | ||||
-rw-r--r-- | src/tag/TagId3.hxx | 9 |
14 files changed, 47 insertions, 29 deletions
diff --git a/src/DecoderThread.cxx b/src/DecoderThread.cxx index a018b3502..5d36a915d 100644 --- a/src/DecoderThread.cxx +++ b/src/DecoderThread.cxx @@ -275,7 +275,7 @@ static void decoder_load_replay_gain(Decoder &decoder, const char *path_fs) { ReplayGainInfo info; - if (replay_gain_ape_read(path_fs, info)) + if (replay_gain_ape_read(Path::FromFS(path_fs), info)) decoder_replay_gain(decoder, &info); } diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx index 7df33395b..a34734227 100644 --- a/src/SongUpdate.cxx +++ b/src/SongUpdate.cxx @@ -73,7 +73,7 @@ Song::LoadFile(const char *path_utf8, Directory *parent) * Attempts to load APE or ID3 tags from the specified file. */ static bool -tag_scan_fallback(const char *path, +tag_scan_fallback(Path path, const struct tag_handler *handler, void *handler_ctx) { return tag_ape_scan2(path, handler, handler_ctx) || @@ -94,13 +94,13 @@ Song::UpdateFile() return false; TagBuilder tag_builder; - if (!tag_file_scan(path_fs.c_str(), + if (!tag_file_scan(path_fs, &full_tag_handler, &tag_builder) || !tag_builder.IsDefined()) return false; if (tag_builder.IsEmpty()) - tag_scan_fallback(path_fs.c_str(), &full_tag_handler, + tag_scan_fallback(path_fs, &full_tag_handler, &tag_builder); mtime = st.st_mtime; diff --git a/src/TagFile.cxx b/src/TagFile.cxx index 0e13b0530..785a74987 100644 --- a/src/TagFile.cxx +++ b/src/TagFile.cxx @@ -19,6 +19,7 @@ #include "config.h" #include "TagFile.hxx" +#include "fs/Path.hxx" #include "util/UriUtil.hxx" #include "util/Error.hxx" #include "DecoderList.hxx" @@ -29,15 +30,15 @@ #include <assert.h> bool -tag_file_scan(const char *path_fs, +tag_file_scan(Path path_fs, const struct tag_handler *handler, void *handler_ctx) { - assert(path_fs != nullptr); + assert(!path_fs.IsNull()); assert(handler != nullptr); /* check if there's a suffix and a plugin */ - const char *suffix = uri_get_suffix(path_fs); + const char *suffix = uri_get_suffix(path_fs.c_str()); if (suffix == nullptr) return false; @@ -52,7 +53,7 @@ tag_file_scan(const char *path_fs, do { /* load file tag */ - if (plugin->ScanFile(path_fs, + if (plugin->ScanFile(path_fs.c_str(), *handler, handler_ctx)) break; @@ -61,7 +62,8 @@ tag_file_scan(const char *path_fs, /* open the InputStream (if not already open) */ if (is == nullptr) - is = InputStream::Open(path_fs, mutex, cond, + is = InputStream::Open(path_fs.c_str(), + mutex, cond, IgnoreError()); /* now try the stream_tag() method */ diff --git a/src/TagFile.hxx b/src/TagFile.hxx index 910f7b82b..3a49a04e1 100644 --- a/src/TagFile.hxx +++ b/src/TagFile.hxx @@ -22,6 +22,7 @@ #include "check.h" +class Path; struct tag_handler; /** @@ -29,7 +30,7 @@ struct tag_handler; * but does not invoke the special "APE" and "ID3" scanners. */ bool -tag_file_scan(const char *path_fs, +tag_file_scan(Path path, const struct tag_handler *handler, void *handler_ctx); #endif diff --git a/src/command/FileCommands.cxx b/src/command/FileCommands.cxx index f3cbaa2ef..8c5bbc50f 100644 --- a/src/command/FileCommands.cxx +++ b/src/command/FileCommands.cxx @@ -112,7 +112,7 @@ handle_read_comments(Client &client, gcc_unused int argc, char *argv[]) return CommandResult::ERROR; } - if (!tag_file_scan(path_fs.c_str(), &print_comment_handler, &client)) { + if (!tag_file_scan(path_fs, &print_comment_handler, &client)) { command_error(client, ACK_ERROR_NO_EXIST, "Failed to load file"); return CommandResult::ERROR; diff --git a/src/playlist/EmbeddedCuePlaylistPlugin.cxx b/src/playlist/EmbeddedCuePlaylistPlugin.cxx index ba2bad7f7..b21d78daa 100644 --- a/src/playlist/EmbeddedCuePlaylistPlugin.cxx +++ b/src/playlist/EmbeddedCuePlaylistPlugin.cxx @@ -35,6 +35,7 @@ #include "TagFile.hxx" #include "cue/CueParser.hxx" #include "fs/Traits.hxx" +#include "fs/AllocatedPath.hxx" #include "util/ASCII.hxx" #include <assert.h> @@ -98,13 +99,17 @@ embcue_playlist_open_uri(const char *uri, /* only local files supported */ return NULL; + const auto path_fs = AllocatedPath::FromUTF8(uri); + if (path_fs.IsNull()) + return nullptr; + const auto playlist = new EmbeddedCuePlaylist(); - tag_file_scan(uri, &embcue_tag_handler, playlist); + tag_file_scan(path_fs, &embcue_tag_handler, playlist); if (playlist->cuesheet.empty()) { - tag_ape_scan2(uri, &embcue_tag_handler, playlist); + tag_ape_scan2(path_fs, &embcue_tag_handler, playlist); if (playlist->cuesheet.empty()) - tag_id3_scan(uri, &embcue_tag_handler, playlist); + tag_id3_scan(path_fs, &embcue_tag_handler, playlist); } if (playlist->cuesheet.empty()) { diff --git a/src/tag/ApeLoader.cxx b/src/tag/ApeLoader.cxx index 19f4d06d4..8251efe10 100644 --- a/src/tag/ApeLoader.cxx +++ b/src/tag/ApeLoader.cxx @@ -20,6 +20,7 @@ #include "config.h" #include "ApeLoader.hxx" #include "system/ByteOrder.hxx" +#include "fs/FileSystem.hxx" #include <glib.h> @@ -102,11 +103,9 @@ ape_scan_internal(FILE *fp, ApeTagCallback callback) } bool -tag_ape_scan(const char *path_fs, ApeTagCallback callback) +tag_ape_scan(Path path_fs, ApeTagCallback callback) { - FILE *fp; - - fp = fopen(path_fs, "rb"); + FILE *fp = FOpen(path_fs, "rb"); if (fp == nullptr) return false; diff --git a/src/tag/ApeLoader.hxx b/src/tag/ApeLoader.hxx index a32ab840c..915c363b4 100644 --- a/src/tag/ApeLoader.hxx +++ b/src/tag/ApeLoader.hxx @@ -26,6 +26,8 @@ #include <stddef.h> +class Path; + typedef std::function<bool(unsigned long flags, const char *key, const char *value, size_t value_length)> ApeTagCallback; @@ -38,6 +40,6 @@ typedef std::function<bool(unsigned long flags, const char *key, * present */ bool -tag_ape_scan(const char *path_fs, ApeTagCallback callback); +tag_ape_scan(Path path_fs, ApeTagCallback callback); #endif diff --git a/src/tag/ApeReplayGain.cxx b/src/tag/ApeReplayGain.cxx index 12919690e..cc65fb79d 100644 --- a/src/tag/ApeReplayGain.cxx +++ b/src/tag/ApeReplayGain.cxx @@ -22,6 +22,7 @@ #include "ApeLoader.hxx" #include "ReplayGainInfo.hxx" #include "util/ASCII.hxx" +#include "fs/Path.hxx" #include <string.h> #include <stdlib.h> @@ -59,7 +60,7 @@ replay_gain_ape_callback(unsigned long flags, const char *key, } bool -replay_gain_ape_read(const char *path_fs, ReplayGainInfo &info) +replay_gain_ape_read(Path path_fs, ReplayGainInfo &info) { bool found = false; diff --git a/src/tag/ApeReplayGain.hxx b/src/tag/ApeReplayGain.hxx index f40523550..865add6f1 100644 --- a/src/tag/ApeReplayGain.hxx +++ b/src/tag/ApeReplayGain.hxx @@ -22,9 +22,10 @@ #include "check.h" +class Path; struct ReplayGainInfo; bool -replay_gain_ape_read(const char *path_fs, ReplayGainInfo &info); +replay_gain_ape_read(Path path_fs, ReplayGainInfo &info); #endif diff --git a/src/tag/ApeTag.cxx b/src/tag/ApeTag.cxx index fa2e744c4..1ba645369 100644 --- a/src/tag/ApeTag.cxx +++ b/src/tag/ApeTag.cxx @@ -23,6 +23,7 @@ #include "Tag.hxx" #include "TagTable.hxx" #include "TagHandler.hxx" +#include "fs/Path.hxx" #include <string> @@ -88,7 +89,7 @@ tag_ape_import_item(unsigned long flags, } bool -tag_ape_scan2(const char *path_fs, +tag_ape_scan2(Path path_fs, const struct tag_handler *handler, void *handler_ctx) { bool recognized = false; diff --git a/src/tag/ApeTag.hxx b/src/tag/ApeTag.hxx index 1a7143314..e35edc381 100644 --- a/src/tag/ApeTag.hxx +++ b/src/tag/ApeTag.hxx @@ -22,6 +22,7 @@ #include "TagTable.hxx" +class Path; struct tag_handler; extern const struct tag_table ape_tags[]; @@ -32,7 +33,7 @@ extern const struct tag_table ape_tags[]; * @param path_fs the path of the file in filesystem encoding */ bool -tag_ape_scan2(const char *path_fs, +tag_ape_scan2(Path path_fs, const struct tag_handler *handler, void *handler_ctx); #endif diff --git a/src/tag/TagId3.cxx b/src/tag/TagId3.cxx index 63df529d3..df70a95e5 100644 --- a/src/tag/TagId3.cxx +++ b/src/tag/TagId3.cxx @@ -29,6 +29,8 @@ #include "ConfigGlobal.hxx" #include "Riff.hxx" #include "Aiff.hxx" +#include "fs/Path.hxx" +#include "fs/FileSystem.hxx" #include <glib.h> #include <id3tag.h> @@ -539,9 +541,9 @@ tag_id3_riff_aiff_load(FILE *file) } struct id3_tag * -tag_id3_load(const char *path_fs, Error &error) +tag_id3_load(Path path_fs, Error &error) { - FILE *file = fopen(path_fs, "rb"); + FILE *file = FOpen(path_fs, "rb"); if (file == nullptr) { error.FormatErrno("Failed to open file %s", path_fs); return nullptr; @@ -559,7 +561,7 @@ tag_id3_load(const char *path_fs, Error &error) } bool -tag_id3_scan(const char *path_fs, +tag_id3_scan(Path path_fs, const struct tag_handler *handler, void *handler_ctx) { Error error; diff --git a/src/tag/TagId3.hxx b/src/tag/TagId3.hxx index e453ffb55..44d890337 100644 --- a/src/tag/TagId3.hxx +++ b/src/tag/TagId3.hxx @@ -23,6 +23,7 @@ #include "check.h" #include "Compiler.h" +class Path; struct tag_handler; struct Tag; struct id3_tag; @@ -31,7 +32,7 @@ class Error; #ifdef HAVE_ID3TAG bool -tag_id3_scan(const char *path_fs, +tag_id3_scan(Path path_fs, const struct tag_handler *handler, void *handler_ctx); Tag * @@ -45,7 +46,7 @@ tag_id3_import(struct id3_tag *); * Error will be set) */ struct id3_tag * -tag_id3_load(const char *path_fs, Error &error); +tag_id3_load(Path path_fs, Error &error); /** * Import all tags from the provided id3_tag *tag @@ -57,8 +58,10 @@ scan_id3_tag(struct id3_tag *tag, #else +#include "fs/Path.hxx" + static inline bool -tag_id3_scan(gcc_unused const char *path_fs, +tag_id3_scan(gcc_unused Path path_fs, gcc_unused const struct tag_handler *handler, gcc_unused void *handler_ctx) { |