archive/File, input/Plugin: return InputStreamPtr

This commit is contained in:
Max Kellermann
2017-12-26 20:05:22 +01:00
parent 49619fbd77
commit 7bce6329e3
17 changed files with 60 additions and 63 deletions

View File

@@ -20,10 +20,11 @@
#ifndef MPD_ARCHIVE_FILE_HXX
#define MPD_ARCHIVE_FILE_HXX
#include "input/Ptr.hxx"
class Mutex;
class Cond;
class ArchiveVisitor;
class InputStream;
class ArchiveFile {
public:
@@ -41,8 +42,8 @@ public:
*
* @param path the path within the archive
*/
virtual InputStream *OpenStream(const char *path,
Mutex &mutex, Cond &cond) = 0;
virtual InputStreamPtr OpenStream(const char *path,
Mutex &mutex, Cond &cond) = 0;
};
#endif

View File

@@ -53,8 +53,8 @@ public:
visitor.VisitArchiveEntry(name.c_str());
}
InputStream *OpenStream(const char *path,
Mutex &mutex, Cond &cond) override;
InputStreamPtr OpenStream(const char *path,
Mutex &mutex, Cond &cond) override;
};
class Bzip2InputStream final : public InputStream {
@@ -127,11 +127,11 @@ Bzip2InputStream::~Bzip2InputStream()
BZ2_bzDecompressEnd(&bzstream);
}
InputStream *
InputStreamPtr
Bzip2ArchiveFile::OpenStream(const char *path,
Mutex &mutex, Cond &cond)
{
return new Bzip2InputStream(istream, path, mutex, cond);
return std::make_unique<Bzip2InputStream>(istream, path, mutex, cond);
}
inline bool

View File

@@ -74,8 +74,8 @@ public:
virtual void Visit(ArchiveVisitor &visitor) override;
InputStream *OpenStream(const char *path,
Mutex &mutex, Cond &cond) override;
InputStreamPtr OpenStream(const char *path,
Mutex &mutex, Cond &cond) override;
};
/* archive open && listing routine */
@@ -156,7 +156,7 @@ public:
size_t Read(void *ptr, size_t size) override;
};
InputStream *
InputStreamPtr
Iso9660ArchiveFile::OpenStream(const char *pathname,
Mutex &mutex, Cond &cond)
{
@@ -165,8 +165,8 @@ Iso9660ArchiveFile::OpenStream(const char *pathname,
throw FormatRuntimeError("not found in the ISO file: %s",
pathname);
return new Iso9660InputStream(iso, pathname, mutex, cond,
statbuf);
return std::make_unique<Iso9660InputStream>(iso, pathname, mutex, cond,
statbuf);
}
size_t

View File

@@ -59,8 +59,8 @@ public:
virtual void Visit(ArchiveVisitor &visitor) override;
InputStream *OpenStream(const char *path,
Mutex &mutex, Cond &cond) override;
InputStreamPtr OpenStream(const char *path,
Mutex &mutex, Cond &cond) override;
};
/* archive open && listing routine */
@@ -116,7 +116,7 @@ public:
void Seek(offset_type offset) override;
};
InputStream *
InputStreamPtr
ZzipArchiveFile::OpenStream(const char *pathname,
Mutex &mutex, Cond &cond)
{
@@ -125,9 +125,9 @@ ZzipArchiveFile::OpenStream(const char *pathname,
throw FormatRuntimeError("not found in the ZIP file: %s",
pathname);
return new ZzipInputStream(dir, pathname,
mutex, cond,
_file);
return std::make_unique<ZzipInputStream>(dir, pathname,
mutex, cond,
_file);
}
size_t