Commit 9aec2f01 authored by Max Kellermann's avatar Max Kellermann

archive/File: eliminate Close(), make destructor virtual instead

parent 5da45508
......@@ -22,19 +22,12 @@
class Mutex;
class Cond;
struct ArchivePlugin;
class ArchiveVisitor;
class InputStream;
class ArchiveFile {
protected:
/**
* Use Close() instead of delete.
*/
~ArchiveFile() {}
public:
virtual void Close() = 0;
virtual ~ArchiveFile() noexcept = default;
/**
* Visit all entries inside this archive.
......
......@@ -49,10 +49,6 @@ public:
name.erase(len - 4);
}
virtual void Close() override {
delete this;
}
virtual void Visit(ArchiveVisitor &visitor) override {
visitor.VisitArchiveEntry(name.c_str());
}
......
......@@ -72,10 +72,6 @@ public:
void Visit(char *path, size_t length, size_t capacity,
ArchiveVisitor &visitor);
virtual void Close() override {
delete this;
}
virtual void Visit(ArchiveVisitor &visitor) override;
InputStream *OpenStream(const char *path,
......
......@@ -57,10 +57,6 @@ public:
ZzipArchiveFile(std::shared_ptr<ZzipDir> &&_dir)
:dir(std::move(_dir)) {}
virtual void Close() override {
delete this;
}
virtual void Visit(ArchiveVisitor &visitor) override;
InputStream *OpenStream(const char *path,
......
......@@ -177,7 +177,7 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
UpdateArchiveVisitor visitor(*this, *file, directory);
file->Visit(visitor);
file->Close();
delete file;
}
bool
......
......@@ -63,7 +63,7 @@ OpenArchiveInputStream(Path path, Mutex &mutex, Cond &cond)
auto file = archive_file_open(arplug, Path::FromFS(archive));
AtScopeExit(file) {
file->Close();
delete file;
};
return InputStreamPtr(file->OpenStream(filename, mutex, cond));
......
......@@ -93,7 +93,7 @@ try {
MyArchiveVisitor visitor;
file->Visit(visitor);
file->Close();
delete file;
return result;
} catch (const std::exception &e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment