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

This commit is contained in:
Max Kellermann 2017-12-22 16:30:17 +01:00
parent 5da455080b
commit 9aec2f019a
7 changed files with 4 additions and 23 deletions

View File

@ -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.

View File

@ -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());
}

View File

@ -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,

View File

@ -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,

View File

@ -177,7 +177,7 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
UpdateArchiveVisitor visitor(*this, *file, directory);
file->Visit(visitor);
file->Close();
delete file;
}
bool

View File

@ -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));

View File

@ -93,7 +93,7 @@ try {
MyArchiveVisitor visitor;
file->Visit(visitor);
file->Close();
delete file;
return result;
} catch (const std::exception &e) {