Add function getting uncompressed size at zip file.
authorSoyoung Kim <sy037.kim@samsung.com>
Fri, 13 Sep 2013 08:53:01 +0000 (17:53 +0900)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Thu, 19 Sep 2013 16:18:17 +0000 (16:18 +0000)
    * 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
modules/core/src/zip_input.cpp

index 1363fac..b364fe4 100644 (file)
@@ -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<FileInfo> FileInfoList;
@@ -158,6 +159,7 @@ class ZipInput :
      * @return Global archive comment
      */
     const std::string &GetGlobalComment() const;
+    size_t GetTotalUncompressedSize() const;
 };
 } // namespace DPL
 
index c516c79..230200f 100644 (file)
@@ -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<off64_t>(fileInfo.uncompressed_size)
                 )
             );
+        m_totalUncompressedSize += static_cast<size_t>(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