1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00
vcmi/hch/CLodHandler.h
Michał W. Urbańczyk cc7be20b07 Merged most of the changes from trunk.
Because of really huge amount of modifications here I've probably missed some minor stuff. I doubt if it's still compatible with gcc - some changes should be reapplied.
2008-08-02 15:08:03 +00:00

61 lines
1.7 KiB
C++

#ifndef CLODHANDLER_H
#define CLODHANDLER_H
#include "../global.h"
#include <fstream>
#include <vector>
#include <string>
#include "../nodrze.h"
struct SDL_Surface;
class CDefHandler;
class CDefEssential;
namespace boost
{class mutex;};
namespace NLoadHandlerHelp
{
const int dmHelp=0, dmNoExtractingMask=1;
//std::string P1,P2,CurDir;
const int fCHUNK = 50000;
};
struct Entry
{
unsigned char name[12], //filename
hlam_1[4], //???
hlam_2[4]; //probably type of file
std::string nameStr;
int offset, //from beginning
realSize, //size without compression
size; //and with
bool operator<(const std::string & comp) const
{
return nameStr<comp;
}
bool operator<(const Entry & comp) const
{
return nameStr<comp.nameStr;
}
Entry(std::string con): nameStr(con){};
//Entry(unsigned char ): nameStr(con){};
Entry(){};
};
class DLL_EXPORT CLodHandler
{
public:
FILE* FLOD;
nodrze<Entry> entries;
unsigned int totalFiles;
boost::mutex *mutex;
int readNormalNr (unsigned char* bufor, int bytCon, bool cyclic=false); //lod header reading helper
int infs(unsigned char * in, int size, int realSize, std::ofstream & out, int wBits=15); //zlib fast handler
int infs2(unsigned char * in, int size, int realSize, unsigned char*& out, int wBits=15); //zlib fast handler
unsigned char * giveFile(std::string defName, int * length=NULL); //returns pointer to the decompressed data - it must be deleted when no longer needed!
std::string getTextFile(std::string name); //extracts one file
void extract(std::string FName);
void extractFile(std::string FName, std::string name); //extracts a specific file
void init(std::string lodFile, std::string dirName);
};
#endif //CLODHANDLER_H