source: Vago/Libs/quazip-0.7.2/quazip/quacrc32.cpp@ 1066

Last change on this file since 1066 was 1050, checked in by s10k, 8 years ago
File size: 1.3 KB
RevLine 
[1050]1/*
2Copyright (C) 2005-2014 Sergey A. Tachenov
3
4This file is part of QuaZIP.
5
6QuaZIP is free software: you can redistribute it and/or modify
7it under the terms of the GNU Lesser General Public License as published by
8the Free Software Foundation, either version 2.1 of the License, or
9(at your option) any later version.
10
11QuaZIP is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU Lesser General Public License for more details.
15
16You should have received a copy of the GNU Lesser General Public License
17along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
18
19See COPYING file for the full LGPL text.
20
21Original ZIP package is copyrighted by Gilles Vollant and contributors,
22see quazip/(un)zip.h files for details. Basically it's the zlib license.
23*/
24
25#include "quacrc32.h"
26
27#include "zlib.h"
28
29QuaCrc32::QuaCrc32()
30{
31 reset();
32}
33
34quint32 QuaCrc32::calculate(const QByteArray &data)
35{
36 return crc32( crc32(0L, Z_NULL, 0), (const Bytef*)data.data(), data.size() );
37}
38
39void QuaCrc32::reset()
40{
41 checksum = crc32(0L, Z_NULL, 0);
42}
43
44void QuaCrc32::update(const QByteArray &buf)
45{
46 checksum = crc32( checksum, (const Bytef*)buf.data(), buf.size() );
47}
48
49quint32 QuaCrc32::value()
50{
51 return checksum;
52}
Note: See TracBrowser for help on using the repository browser.