CLodHandler.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. // Info extracted from LOD file
  31. std::string nameStr;
  32. int offset, //from beginning
  33. realSize, //size without compression
  34. size; //and with
  35. bool operator<(const std::string & comp) const
  36. {
  37. return nameStr<comp;
  38. }
  39. bool operator<(const Entry & comp) const
  40. {
  41. return nameStr<comp.nameStr;
  42. }
  43. Entry(std::string con): nameStr(con){};
  44. //Entry(unsigned char ): nameStr(con){};
  45. Entry(){};
  46. };
  47. class DLL_EXPORT CLodHandler
  48. {
  49. public:
  50. FILE* FLOD;
  51. nodrze<Entry> entries;
  52. unsigned int totalFiles;
  53. boost::mutex *mutex;
  54. std::string myDir; //load files from this dir instead of .lod file
  55. CLodHandler();
  56. ~CLodHandler();
  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__