CLodHandler.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. /*
  9. * CLodhandler.h, part of VCMI engine
  10. *
  11. * Authors: listed in file AUTHORS in main folder
  12. *
  13. * License: GNU General Public License v2.0 or later
  14. * Full text of license available in license.txt file, in main folder
  15. *
  16. */
  17. struct SDL_Surface;
  18. class CDefHandler;
  19. class CDefEssential;
  20. namespace boost
  21. {class mutex;};
  22. namespace NLoadHandlerHelp
  23. {
  24. const int dmHelp=0, dmNoExtractingMask=1;
  25. //std::string P1,P2,CurDir;
  26. const int fCHUNK = 50000;
  27. };
  28. struct Entry
  29. {
  30. unsigned char name[12], //filename
  31. hlam_1[4], //???
  32. hlam_2[4]; //probably type of file
  33. std::string nameStr;
  34. int offset, //from beginning
  35. realSize, //size without compression
  36. size; //and with
  37. bool operator<(const std::string & comp) const
  38. {
  39. return nameStr<comp;
  40. }
  41. bool operator<(const Entry & comp) const
  42. {
  43. return nameStr<comp.nameStr;
  44. }
  45. Entry(std::string con): nameStr(con){};
  46. //Entry(unsigned char ): nameStr(con){};
  47. Entry(){};
  48. };
  49. class DLL_EXPORT CLodHandler
  50. {
  51. public:
  52. FILE* FLOD;
  53. nodrze<Entry> entries;
  54. unsigned int totalFiles;
  55. boost::mutex *mutex;
  56. std::string myDir; //load files from this dir instead of .lod file
  57. int readNormalNr (unsigned char* bufor, int bytCon, bool cyclic=false); //lod header reading helper
  58. int infs(unsigned char * in, int size, int realSize, std::ofstream & out, int wBits=15); //zlib fast handler
  59. int infs2(unsigned char * in, int size, int realSize, unsigned char*& out, int wBits=15); //zlib fast handler
  60. unsigned char * giveFile(std::string defName, int * length=NULL); //returns pointer to the decompressed data - it must be deleted when no longer needed!
  61. std::string getTextFile(std::string name); //extracts one file
  62. void extract(std::string FName);
  63. void extractFile(std::string FName, std::string name); //extracts a specific file
  64. void init(std::string lodFile, std::string dirName);
  65. };
  66. #endif // __CLODHANDLER_H__