misc/quazip/quacrc32.cpp
author nemo
Fri, 23 Mar 2012 18:20:59 -0400
changeset 6810 5337f554480e
parent 5752 ea95ee97c805
permissions -rw-r--r--
This has bugged me for a while. Since we are missing the source SVGs for this theme, removed the leaves crudely in GIMP. Also added some basic roots. Someone more artistic is encouraged to try and improve it.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5752
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     1
#include "quacrc32.h"
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     2
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     3
#include "zlib.h"
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     4
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     5
QuaCrc32::QuaCrc32()
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     6
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     7
	reset();
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     8
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     9
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    10
quint32 QuaCrc32::calculate(const QByteArray &data)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    11
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    12
	return crc32( crc32(0L, Z_NULL, 0), (const Bytef*)data.data(), data.size() );
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    13
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    14
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    15
void QuaCrc32::reset()
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    16
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    17
	checksum = crc32(0L, Z_NULL, 0);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    18
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    19
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    20
void QuaCrc32::update(const QByteArray &buf)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    21
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    22
	checksum = crc32( checksum, (const Bytef*)buf.data(), buf.size() );
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    23
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    24
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    25
quint32 QuaCrc32::value()
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    26
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    27
	return checksum;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    28
}