dictziplib.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef __DICT_ZIP_LIB_H__
  2. #define __DICT_ZIP_LIB_H__
  3. #include <ctime>
  4. #include <string>
  5. #include <zlib.h>
  6. #include "mapfile.hpp"
  7. #define DICT_CACHE_SIZE 5
  8. struct dictCache
  9. {
  10. int chunk;
  11. char *inBuffer;
  12. int stamp;
  13. int count;
  14. };
  15. struct dictData
  16. {
  17. dictData()
  18. {}
  19. bool open(const std::string& filename, int computeCRC);
  20. void close();
  21. void read(char *buffer, unsigned long start, unsigned long size);
  22. ~dictData()
  23. {
  24. close();
  25. }
  26. private:
  27. const char *start; /* start of mmap'd area */
  28. const char *end; /* end of mmap'd area */
  29. unsigned long size; /* size of mmap */
  30. int type;
  31. z_stream zStream;
  32. int initialized;
  33. int headerLength;
  34. int method;
  35. int flags;
  36. time_t mtime;
  37. int extraFlags;
  38. int os;
  39. int version;
  40. int chunkLength;
  41. int chunkCount;
  42. int *chunks;
  43. unsigned long *offsets; /* Sum-scan of chunks. */
  44. std::string origFilename;
  45. std::string comment;
  46. unsigned long crc;
  47. unsigned long length;
  48. unsigned long compressedLength;
  49. dictCache cache[DICT_CACHE_SIZE];
  50. MapFile mapfile;
  51. int read_header(const std::string &filename, int computeCRC);
  52. };
  53. #endif//!__DICT_ZIP_LIB_H__