diff options
author | pixel <pixel> | 2003-10-09 10:25:16 +0000 |
---|---|---|
committer | pixel <pixel> | 2003-10-09 10:25:16 +0000 |
commit | 0894358d10a8016fed253b9c9d3ff7e905b81def (patch) | |
tree | 5e7269ed688448b082013c63131c0c97a0e00a6e /lib | |
parent | d2ea5b4ea490388ea5fb5cc7a54bafd464d13243 (diff) |
Switched Archives "archive" to use "Handle *" instead of "Input"
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Input.cc | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/Input.cc b/lib/Input.cc index c77120c..25862e3 100644 --- a/lib/Input.cc +++ b/lib/Input.cc @@ -193,8 +193,17 @@ Stdin_t Stdin; Archive * Archive::header = 0; -Archive::Archive(const String & fname, int atype) throw (GeneralException) : - name(fname), archive(fname), type(atype) { +Archive::Archive(const String & fname, int atype) : + name(fname), archive(new Input(fname)), type(atype) { + create(); +} + +Archive::Archive(Handle * hand, int atype) : + name(hand->GetName()), archive(hand), type(atype) { + create(); +} + +void Archive::create() { char buffer[1024]; int len; size_t size; @@ -203,18 +212,18 @@ Archive::Archive(const String & fname, int atype) throw (GeneralException) : switch(type) { case ARCHIVE_BUILTIN: - archive.read(buffer, 4); + archive->read(buffer, 4); if (*((Uint32 *)buffer) != BUILTIN_SIG) throw GeneralException(_("Archive: not in built-in format.")); while (p) { - archive.read(buffer, 1); + archive->read(buffer, 1); len = *buffer; if (len) { - archive.read(buffer, len); + archive->read(buffer, len); buffer[len] = 0; ifname = buffer; - size = archive.readU32(); - archive.read(buffer, 1); + size = archive->readU32(); + archive->read(buffer, 1); #ifdef DEBUG printm(M_BARE, _("Adding file `") + ifname + _("' to node `") + p->name + "'\n"); #endif @@ -225,7 +234,7 @@ Archive::Archive(const String & fname, int atype) throw (GeneralException) : p = p->Father(); } } - filetree.compute_ptrs(archive.tell()); + filetree.compute_ptrs(archive->tell()); break; default: throw GeneralException(_("Archive: unsupported archive format.")); @@ -236,7 +245,6 @@ Archive::Archive(const String & fname, int atype) throw (GeneralException) : header = this; if (next) next->prev = this; - } Archive::~Archive() { @@ -246,6 +254,8 @@ Archive::~Archive() { next->prev = prev; if (header == this) header = next; + + delete archive; } bool Archive::inarchive(const String & fname) { @@ -345,7 +355,7 @@ int Archive::openin(const String & fname, Input::openresults_t * results) throw results->ptr = p->ptr; results->size = p->size; results->type = p->type; - return archive.Dup(); + return archive->Dup(); } Archive::FileTree::FileTree(const String & fname, size_t fsize, int ftype, Archive::FileTree * fFather) : |