From 5550ca59370b30525d325b32c05dcc11d97103d8 Mon Sep 17 00:00:00 2001 From: Soyoung Kim Date: Fri, 13 Sep 2013 17:53:01 +0900 Subject: [PATCH] Add function getting uncompressed size at zip file. * wrt-installer should be able to check low memory at installation time [Issue#] WGL-299 [Problem] There is no function to get uncompressed size. [Cause] N/A [Solution] Uncompressed size can be calcuated before unzip during installation. [SCMRequest] N/A Change-Id: I403242b0af066fd22826843095fea12ce95370bb --- modules/core/include/dpl/zip_input.h | 2 ++ modules/core/src/zip_input.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/core/include/dpl/zip_input.h b/modules/core/include/dpl/zip_input.h index 1363fac..b364fe4 100644 --- a/modules/core/include/dpl/zip_input.h +++ b/modules/core/include/dpl/zip_input.h @@ -105,6 +105,7 @@ class ZipInput : size_t m_numberOfFiles; size_t m_globalCommentSize; std::string m_globalComment; + size_t m_totalUncompressedSize; // At least cache handles typedef std::vector FileInfoList; @@ -158,6 +159,7 @@ class ZipInput : * @return Global archive comment */ const std::string &GetGlobalComment() const; + size_t GetTotalUncompressedSize() const; }; } // namespace DPL diff --git a/modules/core/src/zip_input.cpp b/modules/core/src/zip_input.cpp index c516c79..230200f 100644 --- a/modules/core/src/zip_input.cpp +++ b/modules/core/src/zip_input.cpp @@ -293,7 +293,8 @@ ZipInput::ZipInput(const std::string &fileName) : m_device(NULL), m_numberOfFiles(0), m_globalComment(), - m_fileInfos() + m_fileInfos(), + m_totalUncompressedSize(0) { LogPedantic("Zip input file: " << fileName); @@ -451,6 +452,7 @@ void ZipInput::ReadInfos(void *masterFile) static_cast(fileInfo.uncompressed_size) ) ); + m_totalUncompressedSize += static_cast(fileInfo.uncompressed_size); // If this is not the last file, go to next one if (i != m_numberOfFiles - 1) { @@ -627,4 +629,9 @@ bool ZipInput::empty() const { return m_fileInfos.empty(); } + +size_t ZipInput::GetTotalUncompressedSize() const +{ + return m_totalUncompressedSize; +} } // namespace DPL -- 2.7.4