X-Git-Url: https://harrygodden.com/git/?p=csRadar.git;a=blobdiff_plain;f=vpk.h;h=436994d0f9c493299d02382b71ec5c65874830ce;hp=73ff7cb75f9126aee4aeb8192f00519ab9cb0af8;hb=HEAD;hpb=a97099abba0a239e20929f04ece9d6839c96ac14 diff --git a/vpk.h b/vpk.h index 73ff7cb..436994d 100644 --- a/vpk.h +++ b/vpk.h @@ -1,8 +1,26 @@ +// This software is not affiliated with Valve Corporation +// We are not affiliated, associated, authorized, endorsed by, or in any way officially +// connected with Valve Corporation, or any of its subsidiaries or its affiliates. +// +// All trademarks are property of their respective owners + +// Valve pak file directory reader + // VPK //======================================================================================================================= +typedef struct VPKHeader VPKHeader; +typedef struct VPKDirectoryEntry VPKDirectoryEntry; + +// API +// --- + +// There is no load function, reading the header file as binary is enough. +VPKDirectoryEntry *vpk_find( VPKHeader *self, const char *asset ); +void vpk_free( VPKHeader *self ); + #pragma pack(push, 1) -typedef struct +struct VPKHeader { u32 Signature; u32 Version; @@ -11,10 +29,9 @@ typedef struct u32 ArchiveMD5SectionSize; u32 OtherMD5SectionSize; u32 SignatureSectionSize; -} -VPKHeader; +}; -typedef struct +struct VPKDirectoryEntry { u32 CRC; u16 PreloadBytes; @@ -22,10 +39,11 @@ typedef struct u32 EntryOffset; u32 EntryLength; u16 Terminator; -} -VPKDirectoryEntry; +}; #pragma pack(pop) +#ifdef VALVE_IMPLEMENTATION + void vpk_free( VPKHeader *self ) { free( self ); @@ -50,8 +68,8 @@ VPKDirectoryEntry *vpk_find( VPKHeader *self, const char *asset ) while( 1 ) { if( !*pCur ) break; - - int bExt = !strcmp( ext, pCur ); + + int bExt = !strcmp( ext, pCur ); while( *( pCur ++ ) ) {}; while( 1 ) @@ -86,3 +104,5 @@ VPKDirectoryEntry *vpk_find( VPKHeader *self, const char *asset ) return NULL; } + +#endif