diff options
author | Yuri Gorshenin <y@maps.me> | 2016-05-10 15:44:09 +0300 |
---|---|---|
committer | Yuri Gorshenin <y@maps.me> | 2016-05-11 15:58:57 +0300 |
commit | c9086ce741cf93eecada71a0f8e411476d66f1ff (patch) | |
tree | c1b1125a34304d55860bf6c730cc2a2003ae4704 /coding/zip_reader.hpp | |
parent | 18287be1dbd25e98d3ac59e13a86687c5e697605 (diff) |
Review fixes.
Diffstat (limited to 'coding/zip_reader.hpp')
-rw-r--r-- | coding/zip_reader.hpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/coding/zip_reader.hpp b/coding/zip_reader.hpp index 7970cff087..bea0496ae5 100644 --- a/coding/zip_reader.hpp +++ b/coding/zip_reader.hpp @@ -1,6 +1,7 @@ #pragma once #include "coding/file_reader.hpp" +#include "coding/file_writer.hpp" #include "base/exception.hpp" @@ -13,6 +14,17 @@ private: uint64_t m_uncompressedFileSize; public: + struct Delegate + { + virtual ~Delegate() = default; + + // When |size| is zero, end of file is reached. + virtual void OnBlockUnzipped(size_t size, char const * data) = 0; + + virtual void OnStarted() {} + virtual void OnCompleted() {} + }; + typedef function<void(uint64_t, uint64_t)> ProgressFn; /// Contains file name inside zip and it's uncompressed size typedef vector<pair<string, uint32_t> > FileListT; @@ -29,13 +41,9 @@ public: uint64_t UncompressedSize() const { return m_uncompressedFileSize; } /// @warning Can also throw Writer::OpenException and Writer::WriteException + static void UnzipFile(string const & zipContainer, string const & fileInZip, Delegate & delegate); static void UnzipFile(string const & zipContainer, string const & fileInZip, - string const & outFilePath, ProgressFn progressFn = ProgressFn()); - - /// Unzips |file| in |cont| to |buffer|. - /// - /// @warning Can throw OpenZipException and LocateZipException. - static void UnzipFileToMemory(string const & cont, string const & file, vector<char> & data); + string const & outPath); static void FilesList(string const & zipContainer, FileListT & filesList); |