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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#ifndef __COMPRESSOR_H__
#define __COMPRESSOR_H__
#include <string>
#include <iostream>
#include <list>
#include <fstream>
#include "format.h"
class Entry
{
public:
std::wstring name;
int realSize;
int offset;
int packedSize;
int comprLevel;
std::wstring group;
std::wstring fileName;
Formatter *formatter;
public:
Entry(const std::wstring &n, int level, const std::wstring &grp,
const std::wstring &fn, Formatter *frmt):
name(n), group(grp), fileName(fn)
{
comprLevel = level;
offset = packedSize = realSize = 0;
formatter = frmt;
};
};
class ResourceCompressor
{
private:
typedef std::list<Entry> Entries;
Entries entries;
int priority;
Buffer unpackedBuffer, packedBuffer;
std::ostream *stream;
bool dontDeleteStream;
public:
ResourceCompressor();
~ResourceCompressor();
public:
void add(const Entry &entry) { entries.push_back(entry); }
void setPriority(int p) { priority = p; };
void compress(const std::string &outputFile, bool verbose);
void printDeps(const std::string &outputFile,
const std::string &sourceFile);
private:
void adjustBuffers(int fileSize);
int writeHeader();
void compressEntry(Entry &entry, int &offset);
void showEntryStat(Entry &entry);
void writeFooter(int &offset);
void openStream(const std::string &outputFile);
void closeStream();
void readData(const std::wstring &fileName);
void runFormatter(Formatter *formatter, const std::wstring &fileName);
};
#endif
|