CLodHandler.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. std::string myDir; //load files from this dir instead of .lod file
  48. int readNormalNr (unsigned char* bufor, int bytCon, bool cyclic=false); //lod header reading helper
  49. int infs(unsigned char * in, int size, int realSize, std::ofstream & out, int wBits=15); //zlib fast handler
  50. int infs2(unsigned char * in, int size, int realSize, unsigned char*& out, int wBits=15); //zlib fast handler
  51. unsigned char * giveFile(std::string defName, int * length=NULL); //returns pointer to the decompressed data - it must be deleted when no longer needed!
  52. std::string getTextFile(std::string name); //extracts one file
  53. void extract(std::string FName);
  54. void extractFile(std::string FName, std::string name); //extracts a specific file
  55. void init(std::string lodFile, std::string dirName);
  56. };
  57. #endif // __CLODHANDLER_H__