summaryrefslogtreecommitdiff
path: root/zen/zlib_wrap.h
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-02-15 11:50:31 -0500
committerB Stack <bgstack15@gmail.com>2020-02-15 11:50:31 -0500
commit791b90b9898cc41869538f1dfc303588436682b7 (patch)
tree02cc7f817d95ce3f21207cbaba130e3d537fc1eb /zen/zlib_wrap.h
parentMerge branch '10.19' into 'master' (diff)
downloadFreeFileSync-791b90b9898cc41869538f1dfc303588436682b7.tar.gz
FreeFileSync-791b90b9898cc41869538f1dfc303588436682b7.tar.bz2
FreeFileSync-791b90b9898cc41869538f1dfc303588436682b7.zip
add upstream 10.20
It is worth noting that the send email feature is not present in the GPL release.
Diffstat (limited to 'zen/zlib_wrap.h')
-rw-r--r--zen/zlib_wrap.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/zen/zlib_wrap.h b/zen/zlib_wrap.h
index 9d9229ac..b820a4f8 100644
--- a/zen/zlib_wrap.h
+++ b/zen/zlib_wrap.h
@@ -27,8 +27,8 @@ BinContainer decompress(const BinContainer& stream); //throw SysError
class InputStreamAsGzip //convert input stream into gzip on the fly
{
public:
- InputStreamAsGzip( //throw SysError
- const std::function<size_t(void* buffer, size_t bytesToRead)>& readBlock /*throw X*/); //returning 0 signals EOF: Posix read() semantics
+ explicit InputStreamAsGzip( //throw SysError
+ const std::function<size_t(void* buffer, size_t bytesToRead)>& readBlock /*throw X; returning 0 signals EOF: Posix read() semantics*/);
~InputStreamAsGzip();
size_t read(void* buffer, size_t bytesToRead); //throw SysError, X; return "bytesToRead" bytes unless end of stream!
@@ -38,6 +38,7 @@ private:
const std::unique_ptr<Impl> pimpl_;
};
+std::string compressAsGzip(const void* buffer, size_t bufSize); //throw SysError
@@ -103,10 +104,9 @@ BinContainer decompress(const BinContainer& stream) //throw SysError
{
contOut.resize(static_cast<size_t>(uncompressedSize)); //throw std::bad_alloc
}
- catch (const std::bad_alloc& e) //most likely due to data corruption!
- {
- throw SysError(L"zlib error: " + _("Out of memory.") + L" " + utfTo<std::wstring>(e.what()));
- }
+ //most likely this is due to data corruption:
+ catch (const std::length_error& e) { throw SysError(L"zlib error: " + _("Out of memory.") + L" " + utfTo<std::wstring>(e.what())); }
+ catch (const std::bad_alloc& e) { throw SysError(L"zlib error: " + _("Out of memory.") + L" " + utfTo<std::wstring>(e.what())); }
const size_t bytesWritten = impl::zlib_decompress(&*stream.begin() + sizeof(uncompressedSize),
stream.size() - sizeof(uncompressedSize),
bgstack15