diff options
Diffstat (limited to '')
-rw-r--r-- | src/decoder/DecoderThread.cxx | 4 | ||||
-rw-r--r-- | src/input/LocalOpen.cxx | 15 | ||||
-rw-r--r-- | src/input/Open.cxx | 8 | ||||
-rw-r--r-- | src/input/plugins/ArchiveInputPlugin.cxx | 21 | ||||
-rw-r--r-- | src/input/plugins/FileInputPlugin.cxx | 19 |
5 files changed, 34 insertions, 33 deletions
diff --git a/src/decoder/DecoderThread.cxx b/src/decoder/DecoderThread.cxx index 257a0d4ae..a39cfa6e9 100644 --- a/src/decoder/DecoderThread.cxx +++ b/src/decoder/DecoderThread.cxx @@ -115,9 +115,7 @@ decoder_input_stream_open(DecoderControl &dc, Path path) InputStream *is = OpenLocalInputStream(path, dc.mutex, dc.cond, error); if (is == nullptr) { - if (error.IsDefined()) - LogError(error); - + LogError(error); return nullptr; } diff --git a/src/input/LocalOpen.cxx b/src/input/LocalOpen.cxx index a1ac2b856..ad8eba8ce 100644 --- a/src/input/LocalOpen.cxx +++ b/src/input/LocalOpen.cxx @@ -31,6 +31,10 @@ #include <assert.h> +#ifdef ENABLE_ARCHIVE +#include <errno.h> +#endif + InputStream * OpenLocalInputStream(Path path, Mutex &mutex, Cond &cond, Error &error) { @@ -38,8 +42,15 @@ OpenLocalInputStream(Path path, Mutex &mutex, Cond &cond, Error &error) InputStream *is = OpenFileInputStream(path, mutex, cond, error); #ifdef ENABLE_ARCHIVE - if (is == nullptr && !error.IsDefined()) - is = OpenArchiveInputStream(path, mutex, cond, error); + if (is == nullptr && error.IsDomain(errno_domain) && + error.GetCode() == ENOTDIR) { + /* ENOTDIR means this may be a path inside an archive + file */ + Error error2; + is = OpenArchiveInputStream(path, mutex, cond, error2); + if (is == nullptr && error2.IsDefined()) + error = std::move(error2); + } #endif assert(is == nullptr || is->IsReady()); diff --git a/src/input/Open.cxx b/src/input/Open.cxx index 6e89569d6..18572d6b2 100644 --- a/src/input/Open.cxx +++ b/src/input/Open.cxx @@ -21,7 +21,10 @@ #include "InputStream.hxx" #include "Registry.hxx" #include "InputPlugin.hxx" +#include "LocalOpen.hxx" #include "plugins/RewindInputPlugin.hxx" +#include "fs/Traits.hxx" +#include "fs/Path.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" @@ -32,6 +35,11 @@ InputStream::Open(const char *url, Mutex &mutex, Cond &cond, Error &error) { + if (PathTraitsFS::IsAbsolute(url)) + /* TODO: the parameter is UTF-8, not filesystem charset */ + return OpenLocalInputStream(Path::FromFS(url), + mutex, cond, error); + input_plugins_for_each_enabled(plugin) { InputStream *is; diff --git a/src/input/plugins/ArchiveInputPlugin.cxx b/src/input/plugins/ArchiveInputPlugin.cxx index 405e97a8c..da3d7ca71 100644 --- a/src/input/plugins/ArchiveInputPlugin.cxx +++ b/src/input/plugins/ArchiveInputPlugin.cxx @@ -71,25 +71,14 @@ OpenArchiveInputStream(Path path, Mutex &mutex, Cond &cond, Error &error) 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) +input_archive_open(gcc_unused const char *filename, + gcc_unused Mutex &mutex, gcc_unused Cond &cond, + gcc_unused Error &error) { - if (!PathTraitsFS::IsAbsolute(pathname)) - return nullptr; + /* dummy method; use OpenArchiveInputStream() instead */ - /* TODO: the parameter is UTF-8, not filesystem charset */ - return OpenArchiveInputStream(Path::FromFS(pathname), - mutex, cond, error); + return nullptr; } const InputPlugin input_plugin_archive = { diff --git a/src/input/plugins/FileInputPlugin.cxx b/src/input/plugins/FileInputPlugin.cxx index 1f9cf6edd..867b5722d 100644 --- a/src/input/plugins/FileInputPlugin.cxx +++ b/src/input/plugins/FileInputPlugin.cxx @@ -68,9 +68,8 @@ OpenFileInputStream(Path path, { const int fd = OpenFile(path, O_RDONLY|O_BINARY, 0); if (fd < 0) { - if (errno != ENOTDIR) - error.FormatErrno("Failed to open \"%s\"", - path.c_str()); + error.FormatErrno("Failed to open \"%s\"", + path.c_str()); return nullptr; } @@ -96,17 +95,13 @@ OpenFileInputStream(Path path, } static InputStream * -input_file_open(const char *filename, - Mutex &mutex, Cond &cond, - Error &error) +input_file_open(gcc_unused const char *filename, + gcc_unused Mutex &mutex, gcc_unused Cond &cond, + gcc_unused Error &error) { - if (!PathTraitsFS::IsAbsolute(filename)) - return nullptr; - - /* TODO: the parameter is UTF-8, not filesystem charset */ - const Path path = Path::FromFS(filename); + /* dummy method; use OpenFileInputStream() instead */ - return OpenFileInputStream(path, mutex, cond, error); + return nullptr; } bool |