File indexing completed on 2025-01-26 04:24:53

0001 /*
0002 Copyright (C) 2005-2014 Sergey A. Tachenov
0003 
0004 This file is part of QuaZIP.
0005 
0006 QuaZIP is free software: you can redistribute it and/or modify
0007 it under the terms of the GNU Lesser General Public License as published by
0008 the Free Software Foundation, either version 2.1 of the License, or
0009 (at your option) any later version.
0010 
0011 QuaZIP is distributed in the hope that it will be useful,
0012 but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 GNU Lesser General Public License for more details.
0015 
0016 You should have received a copy of the GNU Lesser General Public License
0017 along with QuaZIP.  If not, see <http://www.gnu.org/licenses/>.
0018 
0019 See COPYING file for the full LGPL text.
0020 
0021 Original ZIP package is copyrighted by Gilles Vollant and contributors,
0022 see quazip/(un)zip.h files for details. Basically it's the zlib license.
0023 */
0024 
0025 #include "quacrc32.h"
0026 
0027 #include "zlib.h"
0028 
0029 QuaCrc32::QuaCrc32()
0030 {
0031     reset();
0032 }
0033 
0034 quint32 QuaCrc32::calculate(const QByteArray &data)
0035 {
0036     return crc32( crc32(0L, Z_NULL, 0), (const Bytef*)data.data(), data.size() );
0037 }
0038 
0039 void QuaCrc32::reset()
0040 {
0041     checksum = crc32(0L, Z_NULL, 0);
0042 }
0043 
0044 void QuaCrc32::update(const QByteArray &buf)
0045 {
0046     checksum = crc32( checksum, (const Bytef*)buf.data(), buf.size() );
0047 }
0048 
0049 quint32 QuaCrc32::value()
0050 {
0051     return checksum;
0052 }