aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/input/plugins/ArchiveInputPlugin.cxx40
-rw-r--r--src/input/plugins/ArchiveInputPlugin.hxx9
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