From 492d5c2d1101af70fe53ecb2a9850e7f24997079 Mon Sep 17 00:00:00 2001 From: cxl Date: Thu, 2 Jan 2014 10:37:55 +0000 Subject: [PATCH] plugin/Zip: fixed to compile git-svn-id: svn://ultimatepp.org/upp/trunk@6715 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/z.cpp | 23 +++++++++++++++-------- uppsrc/Core/z.h | 1 - uppsrc/plugin/zip/UnZip.cpp | 4 +++- uppsrc/plugin/zip/Zip.cpp | 4 +++- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/uppsrc/Core/z.cpp b/uppsrc/Core/z.cpp index 86a55987b..da4e325ff 100644 --- a/uppsrc/Core/z.cpp +++ b/uppsrc/Core/z.cpp @@ -322,16 +322,23 @@ int64 CopyStream(Stream& dest, Stream& src, int64 count, Gate2 pro return done; } -int64 zPress(Stream& out, Stream& in, int64 size, Gate2 progress, bool gzip, bool compress) +int64 zPress(Stream& out, Stream& in, int64 size, Gate2 progress, bool gzip, bool compress, + dword *crc = NULL) { Zlib zlib; - OutFilterStream outs(out, zlib); - zlib.GZip(gzip); - if(compress) - zlib.Compress(); - else - zlib.Decompress(); - return CopyStream(outs, in, size, progress) >= 0 && !out.IsError() ? outs.GetCount() : -1; + zlib.GZip(gzip).CRC(crc); + bool r; + { + OutFilterStream outs(out, zlib); + if(compress) + zlib.Compress(); + else + zlib.Decompress(); + r = CopyStream(outs, in, size, progress) >= 0 && !out.IsError() ? outs.GetCount() : -1; + } + if(r && crc) + *crc = zlib.GetCRC(); + return r; } int64 ZCompress(Stream& out, Stream& in, int64 size, Gate2 progress) diff --git a/uppsrc/Core/z.h b/uppsrc/Core/z.h index ad691b8e2..e92788852 100644 --- a/uppsrc/Core/z.h +++ b/uppsrc/Core/z.h @@ -73,7 +73,6 @@ public: ~Zlib(); }; - int64 ZCompress(Stream& out, Stream& in, int64 size, Gate2 progress = false); int64 ZCompress(Stream& out, Stream& in, Gate2 progress = false); String ZCompress(const void *data, int64 len, Gate2 progress = false); diff --git a/uppsrc/plugin/zip/UnZip.cpp b/uppsrc/plugin/zip/UnZip.cpp index 38409d209..c84d4cd79 100644 --- a/uppsrc/plugin/zip/UnZip.cpp +++ b/uppsrc/plugin/zip/UnZip.cpp @@ -43,6 +43,8 @@ void UnZip::SkipFile() ReadHeader(); } +int64 zPress(Stream& out, Stream& in, int64 size, Gate2 progress, bool gzip, bool compress, dword *crc); + bool UnZip::ReadFile(Stream& out, Gate2 progress) { dword crc; @@ -66,7 +68,7 @@ bool UnZip::ReadFile(Stream& out, Gate2 progress) } else if(method == 8) - l = ZDecompress(out, *zip, csize, progress, true, &crc); + l = (int)zPress(out, *zip, csize, AsGate64(progress), true, false, &crc); else { SetError(); return false; diff --git a/uppsrc/plugin/zip/Zip.cpp b/uppsrc/plugin/zip/Zip.cpp index c3f650b03..9f12b81d6 100644 --- a/uppsrc/plugin/zip/Zip.cpp +++ b/uppsrc/plugin/zip/Zip.cpp @@ -10,6 +10,8 @@ void Zip::WriteFolder(const char *path, Time tm) WriteFile(~p, 0, p, false, tm); } +int64 zPress(Stream& out, Stream& in, int64 size, Gate2 progress, bool gzip, bool compress, dword *crc); + void Zip::WriteFile(const void *ptr, int size, const char *path, Gate2 progress, Time tm) { File& f = file.Add(); @@ -17,7 +19,7 @@ void Zip::WriteFile(const void *ptr, int size, const char *path, Gate2 StringStream ss; MemReadStream ms(ptr, size); dword crc; - ZCompress(ss, ms, size, progress, true, &crc); + zPress(ss, ms, size, AsGate64(progress), true, true, &crc); String data = ss.GetResult(); const void *r = ~data; int csize = data.GetLength();