2009-04-16 14:14:13 +03:00
|
|
|
#ifndef __CLODHANDLER_H__
|
|
|
|
#define __CLODHANDLER_H__
|
|
|
|
#include "../global.h"
|
|
|
|
#include <fstream>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include "../nodrze.h"
|
|
|
|
|
2009-04-15 17:03:31 +03:00
|
|
|
/*
|
|
|
|
* CLodhandler.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
2009-04-16 14:14:13 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct SDL_Surface;
|
|
|
|
class CDefHandler;
|
|
|
|
class CDefEssential;
|
2009-05-26 07:52:34 +03:00
|
|
|
namespace boost
|
|
|
|
{class mutex;};
|
2009-04-16 14:14:13 +03:00
|
|
|
namespace NLoadHandlerHelp
|
|
|
|
{
|
|
|
|
const int dmHelp=0, dmNoExtractingMask=1;
|
|
|
|
//std::string P1,P2,CurDir;
|
|
|
|
const int fCHUNK = 50000;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Entry
|
|
|
|
{
|
2009-08-02 18:18:35 +03:00
|
|
|
// Info extracted from LOD file
|
2009-05-26 07:52:34 +03:00
|
|
|
std::string nameStr;
|
2009-04-16 14:14:13 +03:00
|
|
|
int offset, //from beginning
|
|
|
|
realSize, //size without compression
|
|
|
|
size; //and with
|
2009-08-02 18:18:35 +03:00
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
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(){};
|
|
|
|
};
|
2009-06-26 18:41:19 +03:00
|
|
|
|
|
|
|
class DLL_EXPORT CLodHandler
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
2009-05-26 07:52:34 +03:00
|
|
|
FILE* FLOD;
|
2009-04-16 14:14:13 +03:00
|
|
|
nodrze<Entry> entries;
|
|
|
|
unsigned int totalFiles;
|
2009-05-26 07:52:34 +03:00
|
|
|
boost::mutex *mutex;
|
2009-04-16 14:14:13 +03:00
|
|
|
std::string myDir; //load files from this dir instead of .lod file
|
|
|
|
|
2009-06-23 11:14:49 +03:00
|
|
|
CLodHandler();
|
|
|
|
~CLodHandler();
|
2009-05-26 07:52:34 +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
|
2009-04-16 14:14:13 +03:00
|
|
|
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
|
2009-05-26 07:52:34 +03:00
|
|
|
void init(std::string lodFile, std::string dirName);
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // __CLODHANDLER_H__
|