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.

117 lines
4.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef ZIP_UNCOMPRESSED_H
  7. #define ZIP_UNCOMPRESSED_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "datamap.h"
  12. #define PKID( a, b ) (((b)<<24)|((a)<<16)|('K'<<8)|'P')
  13. // compressionMethod field
  14. #define ZIP_COMPRESSION_NONE 0
  15. #define ZIP_COMPRESSION_LZMA 14
  16. #pragma pack(1)
  17. struct ZIP_EndOfCentralDirRecord
  18. {
  19. DECLARE_BYTESWAP_DATADESC();
  20. unsigned int signature; // 4 bytes PK56
  21. unsigned short numberOfThisDisk; // 2 bytes
  22. unsigned short numberOfTheDiskWithStartOfCentralDirectory; // 2 bytes
  23. unsigned short nCentralDirectoryEntries_ThisDisk; // 2 bytes
  24. unsigned short nCentralDirectoryEntries_Total; // 2 bytes
  25. unsigned int centralDirectorySize; // 4 bytes
  26. unsigned int startOfCentralDirOffset; // 4 bytes
  27. unsigned short commentLength; // 2 bytes
  28. // zip file comment follows
  29. };
  30. struct ZIP_FileHeader
  31. {
  32. DECLARE_BYTESWAP_DATADESC();
  33. unsigned int signature; // 4 bytes PK12
  34. unsigned short versionMadeBy; // version made by 2 bytes
  35. unsigned short versionNeededToExtract; // version needed to extract 2 bytes
  36. unsigned short flags; // general purpose bit flag 2 bytes
  37. unsigned short compressionMethod; // compression method 2 bytes
  38. unsigned short lastModifiedTime; // last mod file time 2 bytes
  39. unsigned short lastModifiedDate; // last mod file date 2 bytes
  40. unsigned int crc32; // crc-32 4 bytes
  41. unsigned int compressedSize; // compressed size 4 bytes
  42. unsigned int uncompressedSize; // uncompressed size 4 bytes
  43. unsigned short fileNameLength; // file name length 2 bytes
  44. unsigned short extraFieldLength; // extra field length 2 bytes
  45. unsigned short fileCommentLength; // file comment length 2 bytes
  46. unsigned short diskNumberStart; // disk number start 2 bytes
  47. unsigned short internalFileAttribs; // internal file attributes 2 bytes
  48. unsigned int externalFileAttribs; // external file attributes 4 bytes
  49. unsigned int relativeOffsetOfLocalHeader; // relative offset of local header 4 bytes
  50. // file name (variable size)
  51. // extra field (variable size)
  52. // file comment (variable size)
  53. };
  54. struct ZIP_LocalFileHeader
  55. {
  56. DECLARE_BYTESWAP_DATADESC();
  57. unsigned int signature; //local file header signature 4 bytes PK34
  58. unsigned short versionNeededToExtract; // version needed to extract 2 bytes
  59. unsigned short flags; // general purpose bit flag 2 bytes
  60. unsigned short compressionMethod; // compression method 2 bytes
  61. unsigned short lastModifiedTime; // last mod file time 2 bytes
  62. unsigned short lastModifiedDate; // last mod file date 2 bytes
  63. unsigned int crc32; // crc-32 4 bytes
  64. unsigned int compressedSize; // compressed size 4 bytes
  65. unsigned int uncompressedSize; // uncompressed size 4 bytes
  66. unsigned short fileNameLength; // file name length 2 bytes
  67. unsigned short extraFieldLength; // extra field length 2 bytes
  68. // file name (variable size)
  69. // extra field (variable size)
  70. };
  71. //=============================================================================//
  72. // Valve Non standard Extension, Preload Section
  73. // An optional first file in an aligned zip that can be loaded into ram and
  74. // used by the FileSystem to supply header data rather than disk.
  75. // Is is an optimization to prevent the large of amount of small I/O performed
  76. /// by the map loading process.
  77. //=============================================================================//
  78. #define PRELOAD_SECTION_NAME "__preload_section.pre"
  79. #define PRELOAD_HDR_VERSION 3
  80. #define XZIP_COMMENT_LENGTH 32
  81. #define INVALID_PRELOAD_ENTRY ( (unsigned short)-1 )
  82. struct ZIP_PreloadHeader
  83. {
  84. DECLARE_BYTESWAP_DATADESC();
  85. unsigned int Version; // VERSION
  86. unsigned int DirectoryEntries; // Number of zip directory entries.
  87. unsigned int PreloadDirectoryEntries; // Number of preloaded directory entries (equal or less than the zip dir).
  88. unsigned int Alignment; // File alignment of the zip
  89. };
  90. struct ZIP_PreloadDirectoryEntry
  91. {
  92. DECLARE_BYTESWAP_DATADESC();
  93. unsigned int Length; // Length of the file's preload data in bytes
  94. unsigned int DataOffset; // Offset the file data in the .zip, relative to the logical beginning of the preload file.
  95. };
  96. struct ZIP_PreloadRemapTable
  97. {
  98. DECLARE_BYTESWAP_DATADESC();
  99. unsigned short PreloadIndex; // Index into preload directory, entry marked invalid if no preload entry present
  100. };
  101. #pragma pack()
  102. #endif // ZIP_UNCOMPRESSED_H