Counter Strike : Global Offensive Source Code
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.

87 lines
3.3 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef ZIP_UTILS_H
  7. #define ZIP_UTILS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "utlsymbol.h"
  12. class CUtlBuffer;
  13. #include "tier0/dbg.h"
  14. abstract_class IZip
  15. {
  16. public:
  17. virtual void Reset() = 0;
  18. // Add a single file to a zip - maintains the zip's previous alignment state
  19. virtual void AddFileToZip ( const char *relativename, const char *fullpath ) = 0;
  20. // Whether a file is contained in a zip - maintains alignment
  21. virtual bool FileExistsInZip ( const char *pRelativeName ) = 0;
  22. // Reads a file from the zip - maintains alignement
  23. virtual bool ReadFileFromZip ( const char *pRelativeName, bool bTextMode, CUtlBuffer &buf ) = 0;
  24. #ifdef _WIN32
  25. virtual bool ReadFileFromZip ( HANDLE hFile, const char *pRelativeName, bool bTextMode, CUtlBuffer &buf ) = 0;
  26. #endif
  27. // Removes a single file from the zip - maintains alignment
  28. virtual void RemoveFileFromZip ( const char *relativename ) = 0;
  29. // Gets next filename in zip, for walking the directory - maintains alignment
  30. virtual int GetNextFilename ( int id, char *pBuffer, int bufferSize, int &fileSize ) = 0;
  31. // Prints the zip's contents - maintains alignment
  32. virtual void PrintDirectory ( void ) = 0;
  33. // Estimate the size of the Zip (including header, padding, etc.)
  34. virtual unsigned int EstimateSize ( void ) = 0;
  35. // Add buffer to zip as a file with given name - uses current alignment size, default 0 (no alignment)
  36. virtual void AddBufferToZip ( const char *relativename, void *data, int length, bool bTextMode ) = 0;
  37. // Writes out zip file to a buffer - uses current alignment size
  38. // (set by file's previous alignment, or a call to ForceAlignment)
  39. virtual void SaveToBuffer ( CUtlBuffer& outbuf ) = 0;
  40. // Writes out zip file to a filestream - uses current alignment size
  41. // (set by file's previous alignment, or a call to ForceAlignment)
  42. virtual void SaveToDisk ( FILE *fout ) = 0;
  43. #ifdef _WIN32
  44. virtual void SaveToDisk ( HANDLE hFileOut ) = 0;
  45. #endif
  46. // Reads a zip file from a buffer into memory - sets current alignment size to
  47. // the file's alignment size, unless overridden by a ForceAlignment call)
  48. virtual void ParseFromBuffer ( void *buffer, int bufferlength ) = 0;
  49. // Mounts a zip file from the disk
  50. // Only ReadFileFromZip() is supported because the zip file could be >2GB
  51. #ifdef _WIN32
  52. virtual HANDLE ParseFromDisk ( const char *pFilename ) = 0;
  53. #endif
  54. // Forces a specific alignment size for all subsequent file operations, overriding files' previous alignment size.
  55. // Return to using files' individual alignment sizes by passing FALSE.
  56. virtual void ForceAlignment ( bool aligned, bool bCompatibleFormat, unsigned int alignmentSize=0 ) = 0;
  57. virtual unsigned int GetAlignment() = 0;
  58. // Sets the endianess of the zip
  59. virtual void SetBigEndian( bool bigEndian ) = 0;
  60. virtual void ActivateByteSwapping( bool bActivate ) = 0;
  61. // Create/Release additional instances
  62. // Disk Caching is necessary for large zips
  63. static IZip *CreateZip( const char *pDiskCacheWritePath = NULL, bool bSortByName = false );
  64. static void ReleaseZip( IZip *zip );
  65. };
  66. #endif // ZIP_UTILS_H