forked from kenygia/MooseEdit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PakCompressor.cpp
45 lines (37 loc) · 926 Bytes
/
PakCompressor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "PakCompressor.h"
#include <stdint.h>
#include <cstring>
bool PakCompressor::getShouldCompress() const
{
return shouldCompress;
}
void PakCompressor::setShouldCompress(bool value)
{
shouldCompress = value;
}
bool PakCompressor::getHighCompressionMode() const
{
return highCompressionMode;
}
void PakCompressor::setHighCompressionMode(bool value)
{
highCompressionMode = value;
}
int PakCompressor::compress(const char* source, char* dest, int sourceSize) {
if (shouldCompress) {
if (highCompressionMode) {
return LZ4_compressHC(source, dest, sourceSize);
} else {
return LZ4_compress(source, dest, sourceSize);
}
} else {
memcpy(dest, source, sourceSize);
}
return sourceSize;
}
int PakCompressor::decompress(char *dest, char *src, int compressedSize, int decompressedSize) {
return LZ4_decompress_safe(src, dest, compressedSize, decompressedSize);
}
PakCompressor::PakCompressor()
{
}