CLodHandler.h 2.1 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. 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. CLodHandler();
  58. ~CLodHandler();
  59. int readNormalNr (unsigned char* bufor, int bytCon, bool cyclic=false); //lod header reading helper
  60. int infs(unsigned char * in, int size, int realSize, std::ofstream & out, int wBits=15); //zlib fast handler
  61. int infs2(unsigned char * in, int size, int realSize, unsigned char*& out, int wBits=15); //zlib fast handler
  62. unsigned char * giveFile(std::string defName, int * length=NULL); //returns pointer to the decompressed data - it must be deleted when no longer needed!
  63. std::string getTextFile(std::string name); //extracts one file
  64. void extract(std::string FName);
  65. void extractFile(std::string FName, std::string name); //extracts a specific file
  66. void init(std::string lodFile, std::string dirName);
  67. };
  68. #endif // __CLODHANDLER_H__