From 0c461c3859127246c5305ce13744da68aab1aee0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 2 Oct 2014 21:00:38 +0200 Subject: input/archive: export function OpenArchiveInputStream() --- src/input/plugins/ArchiveInputPlugin.cxx | 40 +++++++++++++++++++------------- src/input/plugins/ArchiveInputPlugin.hxx | 9 +++++++ 2 files changed, 33 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/input/plugins/ArchiveInputPlugin.cxx b/src/input/plugins/ArchiveInputPlugin.cxx index b51dc6835..405e97a8c 100644 --- a/src/input/plugins/ArchiveInputPlugin.cxx +++ b/src/input/plugins/ArchiveInputPlugin.cxx @@ -32,26 +32,13 @@ #include -/** - * select correct archive plugin to handle the input stream - * may allow stacking of archive plugins. for example for handling - * tar.gz a gzip handler opens file (through inputfile stream) - * then it opens a tar handler and sets gzip inputstream as - * parent_stream so tar plugin fetches file data from gzip - * plugin and gzip fetches file from disk - */ -static InputStream * -input_archive_open(const char *pathname, - Mutex &mutex, Cond &cond, - Error &error) +InputStream * +OpenArchiveInputStream(Path path, Mutex &mutex, Cond &cond, Error &error) { const ArchivePlugin *arplug; InputStream *is; - if (!PathTraitsFS::IsAbsolute(pathname)) - return nullptr; - - char *pname = strdup(pathname); + char *pname = strdup(path.c_str()); // archive_lookup will modify pname when true is returned const char *archive, *filename, *suffix; if (!archive_lookup(pname, &archive, &filename, &suffix)) { @@ -84,6 +71,27 @@ input_archive_open(const char *pathname, return is; } +/** + * select correct archive plugin to handle the input stream + * may allow stacking of archive plugins. for example for handling + * tar.gz a gzip handler opens file (through inputfile stream) + * then it opens a tar handler and sets gzip inputstream as + * parent_stream so tar plugin fetches file data from gzip + * plugin and gzip fetches file from disk + */ +static InputStream * +input_archive_open(const char *pathname, + Mutex &mutex, Cond &cond, + Error &error) +{ + if (!PathTraitsFS::IsAbsolute(pathname)) + return nullptr; + + /* TODO: the parameter is UTF-8, not filesystem charset */ + return OpenArchiveInputStream(Path::FromFS(pathname), + mutex, cond, error); +} + const InputPlugin input_plugin_archive = { "archive", nullptr, diff --git a/src/input/plugins/ArchiveInputPlugin.hxx b/src/input/plugins/ArchiveInputPlugin.hxx index 024723726..b6158684a 100644 --- a/src/input/plugins/ArchiveInputPlugin.hxx +++ b/src/input/plugins/ArchiveInputPlugin.hxx @@ -20,6 +20,15 @@ #ifndef MPD_INPUT_ARCHIVE_HXX #define MPD_INPUT_ARCHIVE_HXX +class InputStream; +class Path; +class Mutex; +class Cond; +class Error; + extern const struct InputPlugin input_plugin_archive; +InputStream * +OpenArchiveInputStream(Path path, Mutex &mutex, Cond &cond, Error &error); + #endif -- cgit v1.2.3