2
0

CLodHandler.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef CLODHANDLER_H
  2. #define CLODHANDLER_H
  3. #include "../global.h"
  4. #include <fstream>
  5. #include <vector>
  6. #include <string>
  7. #include "../nodrze.h"
  8. struct SDL_Surface;
  9. class CDefHandler;
  10. class CDefEssential;
  11. namespace boost
  12. {class mutex;};
  13. namespace NLoadHandlerHelp
  14. {
  15. const int dmHelp=0, dmNoExtractingMask=1;
  16. //std::string P1,P2,CurDir;
  17. const int fCHUNK = 50000;
  18. };
  19. struct Entry
  20. {
  21. unsigned char name[12], //filename
  22. hlam_1[4], //???
  23. hlam_2[4]; //probably type of file
  24. std::string nameStr;
  25. int offset, //from beginning
  26. realSize, //size without compression
  27. size; //and with
  28. bool operator<(const std::string & comp) const
  29. {
  30. return nameStr<comp;
  31. }
  32. bool operator<(const Entry & comp) const
  33. {
  34. return nameStr<comp.nameStr;
  35. }
  36. Entry(std::string con): nameStr(con){};
  37. //Entry(unsigned char ): nameStr(con){};
  38. Entry(){};
  39. };
  40. class DLL_EXPORT CLodHandler
  41. {
  42. public:
  43. FILE* FLOD;
  44. nodrze<Entry> entries;
  45. unsigned int totalFiles;
  46. boost::mutex *mutex;
  47. int readNormalNr (unsigned char* bufor, int bytCon, bool cyclic=false); //lod header reading helper
  48. int infs(unsigned char * in, int size, int realSize, std::ofstream & out, int wBits=15); //zlib fast handler
  49. int infs2(unsigned char * in, int size, int realSize, unsigned char*& out, int wBits=15); //zlib fast handler
  50. unsigned char * giveFile(std::string defName, int * length=NULL); //returns pointer to the decompressed data - it must be deleted when no longer needed!
  51. std::string getTextFile(std::string name); //extracts one file
  52. void extract(std::string FName);
  53. void extractFile(std::string FName, std::string name); //extracts a specific file
  54. void init(std::string lodFile, std::string dirName);
  55. };
  56. #endif //CLODHANDLER_H