input/archive: export function OpenArchiveInputStream()
This commit is contained in:
parent
0d38bd9b3b
commit
0c461c3859
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user