From d11fa6484ace66be389e6d059f63060730a1ceb6 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Mon, 29 Sep 2008 22:29:07 +0000 Subject: Ported ZipArchive::getAllNames() implementation from GUI branch. svn-id: r34691 --- common/unzip.cpp | 16 +++++++++++++++- common/unzip.h | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/common/unzip.cpp b/common/unzip.cpp index 054200e7a2..775a6e2dab 100644 --- a/common/unzip.cpp +++ b/common/unzip.cpp @@ -1393,7 +1393,21 @@ bool ZipArchive::hasFile(const Common::String &name) { } int ZipArchive::getAllNames(Common::StringList &list) { - return 0; + if (!_zipFile) + return 0; + + if (unzGoToFirstFile(_zipFile) != UNZ_OK) + return 0; + + char fileNameBuffer[UNZ_MAXFILENAMEINZIP + 1]; + list.clear(); + + do { + unzGetCurrentFileInfo(_zipFile, 0, fileNameBuffer, UNZ_MAXFILENAMEINZIP + 1, 0, 0, 0, 0); + list.push_back(Common::String(fileNameBuffer)); + } while (unzGoToNextFile(_zipFile) == UNZ_OK); + + return list.size(); } /* diff --git a/common/unzip.h b/common/unzip.h index 93afd0b05b..e4eb754eee 100644 --- a/common/unzip.h +++ b/common/unzip.h @@ -44,7 +44,7 @@ public: bool isOpen() const; virtual bool hasFile(const String &name); - virtual int getAllNames(StringList &list); // FIXME: This one is not (yet?) implemented + virtual int getAllNames(StringList &list); virtual Common::SeekableReadStream *openFile(const Common::String &name); }; -- cgit v1.2.3