-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCompressedBaseFile.h
32 lines (24 loc) · 1.07 KB
/
CompressedBaseFile.h
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
#ifndef COMPRESSEDBASEFILE_H
#define COMPRESSEDBASEFILE_H
#include "BaseFile.h"
namespace SCRANTIC {
class CompressedBaseFile : public BaseFile {
protected:
u32 compressedSize;
u8 compressionFlag;
u32 uncompressedSize;
bool handleDecompression(v8 &data, v8::iterator &it, v8 &uncompressedData);
static v8 RLECompress(v8 const &compressedData);
static v8 RLEDecompress(v8 const &compressedData, size_t offset = 0, u32 size = 0);
static v8 RLE2Decompress(v8 const &compressedData, size_t offset = 0, u32 size = 0);
static bool findInDictionary(std::vector<v8> &dictionary, v8 currentBlock, u16 &dictPos);
static void writeBits(v8 &data, u8 &bitPos, u16 bits, u8 bitLength);
static u16 readBits(v8 const &data, size_t &bytePos, u8 &bitPos, u16 bits);
static v8 LZCCompress(v8 const &uncompressedData);
static v8 LZCDecompress(v8 const &compressedData, size_t offset = 0, u32 size = 0);
public:
explicit CompressedBaseFile(const std::string &name) : BaseFile(name) {};
~CompressedBaseFile() {};
};
}
#endif // COMPRESSEDBASEFILE_H