diff options
author | Max Horn | 2008-09-23 09:39:37 +0000 |
---|---|---|
committer | Max Horn | 2008-09-23 09:39:37 +0000 |
commit | bfdff06e327ee4660f69ffb576dc24662a6c7362 (patch) | |
tree | e8108fc26bde0dc237747803112c987aa0ddfecb /common/unzip.h | |
parent | 939ba5294f5367c91e178a7b06db0266840f79f3 (diff) | |
download | scummvm-rg350-bfdff06e327ee4660f69ffb576dc24662a6c7362.tar.gz scummvm-rg350-bfdff06e327ee4660f69ffb576dc24662a6c7362.tar.bz2 scummvm-rg350-bfdff06e327ee4660f69ffb576dc24662a6c7362.zip |
Moved ZipArchive implementation into unzip.cpp, added new ZipArchive::isOpen method
svn-id: r34630
Diffstat (limited to 'common/unzip.h')
-rw-r--r-- | common/unzip.h | 44 |
1 files changed, 8 insertions, 36 deletions
diff --git a/common/unzip.h b/common/unzip.h index 43faaf4a74..6133e7c92d 100644 --- a/common/unzip.h +++ b/common/unzip.h @@ -306,46 +306,18 @@ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, #endif -class ZipArchive : Common::Archive { +class ZipArchive : public Common::Archive { unzFile _zipFile; public: - ZipArchive(const Common::String &name) { - _zipFile = unzOpen(name.c_str()); - } - ~ZipArchive() { - unzClose(_zipFile); - } - - virtual bool hasFile(const Common::String &name) { - return (_zipFile && unzLocateFile(_zipFile, name.c_str(), 2) == UNZ_OK); - } - - virtual int getAllNames(Common::StringList &list) { - // TODO - return 0; - } - - virtual Common::SeekableReadStream *openFile(const Common::String &name) { - if (!_zipFile) - return 0; + ZipArchive(const Common::String &name); + ~ZipArchive(); - unzLocateFile(_zipFile, name.c_str(), 2); - - unz_file_info fileInfo; - unzOpenCurrentFile(_zipFile); - unzGetCurrentFileInfo(_zipFile, &fileInfo, NULL, 0, NULL, 0, NULL, 0); - byte *buffer = (byte *)calloc(fileInfo.uncompressed_size+1, 1); - assert(buffer); - unzReadCurrentFile(_zipFile, buffer, fileInfo.uncompressed_size); - unzCloseCurrentFile(_zipFile); - return new Common::MemoryReadStream(buffer, fileInfo.uncompressed_size+1, true); - - // FIXME: instead of reading all into a memory stream, we could - // instead create a new ZipStream class. But then we have to be - // careful to handle the case where the client code opens multiple - // files in the archive and tries to use them indepenendtly. - } + bool isOpen() const { return _zipFile != 0; } + + virtual bool hasFile(const Common::String &name); + virtual int getAllNames(Common::StringList &list); // FIXME: This one is not (yet?) implemented + virtual Common::SeekableReadStream *openFile(const Common::String &name); }; #endif // USE_ZLIB |