Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=====================================================================================//
  6. #pragma once
  7. #include <stdio.h>
  8. #include "utlbuffer.h"
  9. #include "zip_uncompressed.h"
  10. #include "generichash.h"
  11. #include "zip_utils.h"
  12. #include "byteswap.h"
  13. #include "tier1/UtlVector.h"
  14. #include "UtlSortVector.h"
  15. struct CRCEntry_t
  16. {
  17. unsigned int fileNameCRC;
  18. CUtlString filename;
  19. };
  20. struct preloadRemap_t
  21. {
  22. CUtlString filename;
  23. unsigned short preloadDirIndex;
  24. };
  25. class CZipCRCLessFunc
  26. {
  27. public:
  28. bool Less( CRCEntry_t const& src1, CRCEntry_t const& src2, void *pCtx )
  29. {
  30. return ( src1.fileNameCRC < src2.fileNameCRC );
  31. }
  32. };
  33. class CXZipTool
  34. {
  35. public:
  36. CXZipTool();
  37. ~CXZipTool();
  38. void Reset();
  39. bool Begin( const char* pFileName, unsigned int alignment = 0 );
  40. bool End();
  41. bool AddBuffer( const char* pFileName, CUtlBuffer &buffer, bool bPreload = true );
  42. bool AddFile( const char* pFileName, bool bPreload = true );
  43. void SpewPreloadInfo( const char *pZipName );
  44. private:
  45. IZip *m_pZip;
  46. char m_PreloadFilename[MAX_PATH];
  47. HANDLE m_hPreloadFile;
  48. HANDLE m_hOutputZipFile;
  49. ZIP_PreloadHeader m_ZipPreloadHeader;
  50. CUtlVector< ZIP_PreloadDirectoryEntry > m_ZipPreloadDirectoryEntries;
  51. CUtlSortVector< CRCEntry_t, CZipCRCLessFunc > m_ZipCRCList;
  52. CUtlVector< preloadRemap_t > m_ZipPreloadRemapEntries;
  53. };