From 9321c6bdfc559db6cf436d4ea88198983ce59846 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 2 Oct 2015 14:53:55 +0200 Subject: 6.12 --- zen/serialize.h | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'zen/serialize.h') diff --git a/zen/serialize.h b/zen/serialize.h index cd427c9c..54baf75a 100644 --- a/zen/serialize.h +++ b/zen/serialize.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -137,35 +137,35 @@ template < class BinInputStream> void readArray (BinInputStream& stre //-----------------------implementation------------------------------- template inline void saveBinStream(const Zstring& filepath, //throw FileError - const BinContainer& cont, - const std::function& onUpdateStatus) //optional + const BinContainer& cont, + const std::function& onUpdateStatus) //optional { static_assert(sizeof(typename BinContainer::value_type) == 1, ""); //expect: bytes (until further) FileOutput fileOut(filepath, zen::FileOutput::ACC_OVERWRITE); //throw FileError if (!cont.empty()) - { - const size_t blockSize = 128 * 1024; - auto bytePtr = &*cont.begin(); - size_t bytesLeft = cont.size(); - - while (bytesLeft > blockSize) - { - fileOut.write(bytePtr, blockSize); //throw FileError - bytePtr += blockSize; - bytesLeft -= blockSize; - if (onUpdateStatus) onUpdateStatus(blockSize); - } - - fileOut.write(bytePtr, bytesLeft); //throw FileError - if (onUpdateStatus) onUpdateStatus(bytesLeft); - } + { + const size_t blockSize = 128 * 1024; + auto bytePtr = &*cont.begin(); + size_t bytesLeft = cont.size(); + + while (bytesLeft > blockSize) + { + fileOut.write(bytePtr, blockSize); //throw FileError + bytePtr += blockSize; + bytesLeft -= blockSize; + if (onUpdateStatus) onUpdateStatus(blockSize); + } + + fileOut.write(bytePtr, bytesLeft); //throw FileError + if (onUpdateStatus) onUpdateStatus(bytesLeft); + } } template inline BinContainer loadBinStream(const Zstring& filepath, //throw FileError - const std::function& onUpdateStatus) //optional + const std::function& onUpdateStatus) //optional { static_assert(sizeof(typename BinContainer::value_type) == 1, ""); //expect: bytes (until further) @@ -181,7 +181,7 @@ BinContainer loadBinStream(const Zstring& filepath, //throw FileError if (bytesRead < blockSize) contOut.resize(contOut.size() - (blockSize - bytesRead)); //caveat: unsigned arithmetics - if (onUpdateStatus) onUpdateStatus(bytesRead); + if (onUpdateStatus) onUpdateStatus(bytesRead); } while (!fileIn.eof()); -- cgit