aboutsummaryrefslogtreecommitdiff
path: root/src/archive/Bzip2ArchivePlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-29 23:26:51 +0100
committerMax Kellermann <max@duempel.org>2013-01-29 23:26:51 +0100
commitf5c0b0d3168d6c34010f86a4b6878b7181d10237 (patch)
tree50304ecc4ab8690c9283051268a393e87e3a9461 /src/archive/Bzip2ArchivePlugin.cxx
parentba51045d9e85b8e48afed629d6d87ac3338acd46 (diff)
ArchiveFile: convert to a class
Diffstat (limited to 'src/archive/Bzip2ArchivePlugin.cxx')
-rw-r--r--src/archive/Bzip2ArchivePlugin.cxx23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/archive/Bzip2ArchivePlugin.cxx b/src/archive/Bzip2ArchivePlugin.cxx
index f9371812..daa04b97 100644
--- a/src/archive/Bzip2ArchivePlugin.cxx
+++ b/src/archive/Bzip2ArchivePlugin.cxx
@@ -23,8 +23,8 @@
#include "config.h"
#include "Bzip2ArchivePlugin.hxx"
-#include "ArchiveInternal.hxx"
#include "ArchivePlugin.hxx"
+#include "ArchiveFile.hxx"
#include "ArchiveVisitor.hxx"
#include "InputInternal.hxx"
#include "InputStream.hxx"
@@ -42,17 +42,14 @@
#define BZ2_bzDecompress bzDecompress
#endif
-struct Bzip2ArchiveFile {
- struct archive_file base;
-
+class Bzip2ArchiveFile : public ArchiveFile {
+public:
RefCount ref;
char *name;
struct input_stream *istream;
- Bzip2ArchiveFile() {
- archive_file_init(&base, &bz2_archive_plugin);
- }
+ Bzip2ArchiveFile():ArchiveFile(bz2_archive_plugin) {}
void Unref() {
if (!ref.Decrement())
@@ -123,7 +120,7 @@ Bzip2InputStream::Close()
/* archive open && listing routine */
-static struct archive_file *
+static ArchiveFile *
bz2_open(const char *pathname, GError **error_r)
{
Bzip2ArchiveFile *context = new Bzip2ArchiveFile();
@@ -147,11 +144,11 @@ bz2_open(const char *pathname, GError **error_r)
context->name[len - 4] = 0; //remove .bz2 suffix
}
- return &context->base;
+ return context;
}
static void
-bz2_visit(archive_file *file, ArchiveVisitor &visitor)
+bz2_visit(ArchiveFile *file, ArchiveVisitor &visitor)
{
Bzip2ArchiveFile *context = (Bzip2ArchiveFile *) file;
@@ -159,7 +156,7 @@ bz2_visit(archive_file *file, ArchiveVisitor &visitor)
}
static void
-bz2_close(struct archive_file *file)
+bz2_close(ArchiveFile *file)
{
Bzip2ArchiveFile *context = (Bzip2ArchiveFile *) file;
@@ -178,11 +175,11 @@ Bzip2InputStream::Bzip2InputStream(Bzip2ArchiveFile &_context, const char *uri,
Bzip2InputStream::~Bzip2InputStream()
{
- bz2_close(&archive->base);
+ archive->Unref();
}
static struct input_stream *
-bz2_open_stream(struct archive_file *file, const char *path,
+bz2_open_stream(ArchiveFile *file, const char *path,
Mutex &mutex, Cond &cond,
GError **error_r)
{