diff options
author | Alex Zolotarev <alex@maps.me> | 2015-08-18 22:02:44 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 03:01:41 +0300 |
commit | dbe1feb585a88510a03cc140a5269b58fd9e7813 (patch) | |
tree | 8e83a4c4b80a643e1e1eee0740d4489f37e81123 /coding/zip_creator.cpp | |
parent | 36e6f0d996f5967a0d3a2f5072b5dadb05aee76c (diff) |
Minor ZipReader improvements.
Diffstat (limited to 'coding/zip_creator.cpp')
-rw-r--r-- | coding/zip_creator.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/coding/zip_creator.cpp b/coding/zip_creator.cpp index 2831100f3c..dca31e1674 100644 --- a/coding/zip_creator.cpp +++ b/coding/zip_creator.cpp @@ -13,7 +13,6 @@ #include "std/vector.hpp" #include "std/ctime.hpp" #include "std/algorithm.hpp" -#include "std/unique_ptr.hpp" #include "3party/minizip/zip.h" @@ -58,8 +57,6 @@ void CreateTMZip(tm_zip & res) bool CreateZipFromPathDeflatedAndDefaultCompression(string const & filePath, string const & zipFilePath) { - unique_ptr<char[]> buffer(new char[ZIP_FILE_BUFFER_SIZE]); - // 2. Open zip file for writing. MY_SCOPE_GUARD(outFileGuard, bind(&my::DeleteFileX, cref(zipFilePath))); ZipHandle zip(zipFilePath); @@ -87,12 +84,13 @@ bool CreateZipFromPathDeflatedAndDefaultCompression(string const & filePath, str uint64_t const fileSize = file.Size(); uint64_t currSize = 0; + char buffer[ZIP_FILE_BUFFER_SIZE]; while (currSize < fileSize) { unsigned int const toRead = min(ZIP_FILE_BUFFER_SIZE, static_cast<unsigned int>(fileSize - currSize)); - file.Read(currSize, &buffer[0], toRead); + file.Read(currSize, buffer, toRead); - if (ZIP_OK != zipWriteInFileInZip(zip.Handle(), &buffer[0], toRead)) + if (ZIP_OK != zipWriteInFileInZip(zip.Handle(), buffer, toRead)) return false; currSize += toRead; |