Commit 0c461c38 authored by Max Kellermann's avatar Max Kellermann

input/archive: export function OpenArchiveInputStream()

parent 0d38bd9b
......@@ -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,
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment