input: wrap InputStream in std::unique_ptr

This commit is contained in:
Max Kellermann
2016-02-21 08:03:32 +01:00
parent 054e9ecaae
commit cadc67ea40
19 changed files with 107 additions and 103 deletions

View File

@@ -35,19 +35,19 @@
#include <errno.h>
#endif
InputStream *
InputStreamPtr
OpenLocalInputStream(Path path, Mutex &mutex, Cond &cond, Error &error)
{
assert(!error.IsDefined());
InputStream *is = OpenFileInputStream(path, mutex, cond, error);
InputStreamPtr is(OpenFileInputStream(path, mutex, cond, error));
#ifdef ENABLE_ARCHIVE
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);
is.reset(OpenArchiveInputStream(path, mutex, cond, error2));
if (is == nullptr && error2.IsDefined())
error = std::move(error2);
}