1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-30 08:57:00 +02:00
vcmi/hch/CLodHandler.h

60 lines
1.7 KiB
C
Raw Normal View History

#ifndef CLODHANDLER_H
#define CLODHANDLER_H
2008-06-12 09:45:51 +03:00
#include "../global.h"
#include <fstream>
#include <vector>
#include <string>
#include "../nodrze.h"
2008-01-09 19:21:31 +02:00
2008-06-12 09:45:51 +03:00
struct SDL_Surface;
2008-01-09 19:21:31 +02:00
class CDefHandler;
class CDefEssential;
2008-06-16 13:51:14 +03:00
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
2008-03-21 02:03:31 +02:00
hlam_1[4], //???
hlam_2[4]; //probably type of file
2007-07-07 14:09:25 +03:00
std::string nameStr;
int offset, //from beginning
realSize, //size without compression
size; //and with
2008-02-03 07:10:33 +02:00
bool operator<(const std::string & comp) const
{
return nameStr<comp;
}
2007-07-07 14:09:25 +03:00
bool operator<(const Entry & comp) const
{
return nameStr<comp.nameStr;
2007-07-07 14:09:25 +03:00
}
Entry(std::string con): nameStr(con){};
//Entry(unsigned char ): nameStr(con){};
2007-07-07 14:09:25 +03:00
Entry(){};
};
2008-06-13 00:08:04 +03:00
class DLL_EXPORT CLodHandler
{
public:
2008-06-12 09:45:51 +03:00
FILE* FLOD;
nodrze<Entry> entries;
unsigned int totalFiles;
2008-06-16 13:51:14 +03:00
boost::mutex *mutex;
2008-06-13 00:08:04 +03:00
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
2008-06-14 13:20:18 +03:00
void init(std::string lodFile, std::string dirName);
};
#endif //CLODHANDLER_H