diff options
author | Max Kellermann <max@duempel.org> | 2014-10-02 21:00:38 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-10-02 21:00:38 +0200 |
commit | 0c461c3859127246c5305ce13744da68aab1aee0 (patch) | |
tree | 6b152a72436c2054c9c6d2d40bf7ce7d3d0e88c7 /src | |
parent | 0d38bd9b3bf9b978c3e9a08324ff8ea764a530bd (diff) | |
download | mpd-0c461c3859127246c5305ce13744da68aab1aee0.tar.gz mpd-0c461c3859127246c5305ce13744da68aab1aee0.tar.xz mpd-0c461c3859127246c5305ce13744da68aab1aee0.zip |
input/archive: export function OpenArchiveInputStream()
Diffstat (limited to 'src')
-rw-r--r-- | src/input/plugins/ArchiveInputPlugin.cxx | 40 | ||||
-rw-r--r-- | src/input/plugins/ArchiveInputPlugin.hxx | 9 |
2 files changed, 33 insertions, 16 deletions
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 <stdlib.h> -/** - * 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 |