CLodHandler.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef CLODHANDLER_H
  2. #define CLODHANDLER_H
  3. #include <iostream>
  4. #include <fstream>
  5. #include <vector>
  6. #include <string>
  7. #include "zlib.h"
  8. #include "CDefHandler.h"
  9. enum Epcxformat {PCX8B, PCX24B};
  10. namespace NLoadHandlerHelp
  11. {
  12. const int dmHelp=0, dmNoExtractingMask=1;
  13. //std::string P1,P2,CurDir;
  14. const int fCHUNK = 50000;
  15. };
  16. struct Entry
  17. {
  18. unsigned char name[12], //filename
  19. hlam_1[4], //
  20. hlam_2[4]; //
  21. std::string nameStr;
  22. int offset, //from beginning
  23. realSize, //size without compression
  24. size; //and with
  25. bool operator<(const Entry & comp) const
  26. {
  27. return this->nameStr<comp.nameStr;
  28. }
  29. Entry(std::string con): nameStr(con){};
  30. Entry(){};
  31. };
  32. class CPCXConv
  33. {
  34. public:
  35. unsigned char * pcx, *bmp;
  36. int pcxs, bmps;
  37. void fromFile(std::string path);
  38. void saveBMP(std::string path);
  39. void openPCX(char * PCX, int len);
  40. void openPCX();
  41. void convert();
  42. CPCXConv(){pcx=bmp=NULL;pcxs=bmps=0;};
  43. ~CPCXConv(){if (pcxs) delete pcx; if(bmps) delete bmp;}
  44. };
  45. class CLodHandler
  46. {
  47. private:
  48. std::ifstream FLOD;
  49. public:
  50. std::vector<Entry> entries;
  51. unsigned int totalFiles;
  52. int readNormalNr (unsigned char* bufor, int bytCon, bool cyclic=false); //lod header reading helper
  53. int decompress (unsigned char * source, int size, int realSize, std::ofstream & dest); //main decompression function
  54. int decompress (unsigned char * source, int size, int realSize, std::string & dest); //main decompression function
  55. int infm(FILE *source, FILE *dest, int wBits = 15); //zlib handler
  56. int infs(unsigned char * in, int size, int realSize, std::ofstream & out, int wBits=15); //zlib fast handler
  57. int infs2(unsigned char * in, int size, int realSize, unsigned char*& out, int wBits=15); //zlib fast handler
  58. std::vector<CDefHandler *> extractManyFiles(std::vector<std::string> defNamesIn, std::string lodName); //extrats given files (defs only)
  59. void extract(std::string FName);
  60. void extractFile(std::string FName, std::string name); //extracts a specific file
  61. void init(std::string lodFile);
  62. };
  63. #endif //CLODHANDLER_H