1
This commit is contained in:
49
vpklib/fileformat.txt
Normal file
49
vpklib/fileformat.txt
Normal file
@ -0,0 +1,49 @@
|
||||
On disk format of directory (xxx_dir.vpk. data is in xxx_000.vpk, xxx_001.vpk, ...)
|
||||
|
||||
|
||||
id
|
||||
records
|
||||
"extension\0" (0 = no more extensions)
|
||||
"dir\0" (0 = no more dirs)
|
||||
"basefilename\0" (0 = no more files of this extension in this dir)
|
||||
orig data file crc
|
||||
int16 metadata size
|
||||
location in data files for level 0 data (word filenum, ulong offset, ulong fsize)
|
||||
location in data files for level 1 data (word filenum, ulong offset, ulong fsize) ..
|
||||
-1.
|
||||
uint8 metadata[]
|
||||
|
||||
|
||||
..
|
||||
..
|
||||
..
|
||||
|
||||
data files
|
||||
|
||||
|
||||
|
||||
[x]step0 - class def, format def
|
||||
[x]step1 - generator
|
||||
[x]step2 - loader
|
||||
[ ]step3 - surrounding file monitor tools + ui
|
||||
|
||||
|
||||
|
||||
A client of the archive who can't handle their persistent meta data going away (as during
|
||||
a reload) can say so, which will cuase their metadata to be copied away at next reload. otherwise,
|
||||
a reload will change the address of the meta data and maybe its size/content.
|
||||
|
||||
|
||||
|
||||
insert
|
||||
|
||||
case file found:
|
||||
find all files in the same data chunk
|
||||
load data chunk.
|
||||
replace old chunk of data, changing offsets in parts of files that were there.
|
||||
replace offset and crc in old dir record
|
||||
case file not found
|
||||
might need to add new extension
|
||||
might need to add new directory
|
||||
insert new file entry
|
||||
add new data to last chunk
|
43
vpklib/mktestpak.pl
Normal file
43
vpklib/mktestpak.pl
Normal file
@ -0,0 +1,43 @@
|
||||
#! perl
|
||||
|
||||
# make a simple fixed pak file for testing code. This utility is only for testing the code
|
||||
# before writing the "real" utility. The files that are packed are fake
|
||||
|
||||
|
||||
|
||||
$ndatfileindex=0;
|
||||
$ndatoffset=0;
|
||||
|
||||
$nullbyte = pack("C",0);
|
||||
|
||||
foreach $ext ("txt","vtf")
|
||||
{
|
||||
$dirout.=$ext.$nullbyte;
|
||||
foreach $dir("dir1","dir2")
|
||||
{
|
||||
$dirout.=$dir.$nullbyte;
|
||||
foreach $file("test1","test2")
|
||||
{
|
||||
$fdata=$file x 5;
|
||||
$dirout.=$dir.$nullbyte;
|
||||
$dirout.=pack("V",0); # fake crc
|
||||
$dirout.=pack("v",0); #meta data size
|
||||
$dirout.=pack("C",$ndatfileindex);
|
||||
$dirout.=pack("V",$ndatoffset);
|
||||
$dirout.=pack("V",length($dataout));
|
||||
$dataout.=$fdata;
|
||||
$dirout.=pack("V",-1);
|
||||
}
|
||||
}
|
||||
$dirout.=$nullbyte;
|
||||
}
|
||||
$dirout.=$nullbyte;
|
||||
|
||||
open(DIROUT,">test.dir") || die;
|
||||
binmode DIROUT;
|
||||
print DIROUT $dirout;
|
||||
close DIROUT;
|
||||
open(DATAOUT,">test_000.dat") || die;
|
||||
binmode DATAOUT;
|
||||
print DATAOUT $dataout;
|
||||
close DATAOUT;
|
2087
vpklib/packedstore.cpp
Normal file
2087
vpklib/packedstore.cpp
Normal file
File diff suppressed because it is too large
Load Diff
60
vpklib/packedstore_internal.h
Normal file
60
vpklib/packedstore_internal.h
Normal file
@ -0,0 +1,60 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#define VPKFILENUMBER_EMBEDDED_IN_DIR_FILE 0x7fff // if a chunk refers to this file number, it is data embedded in the same file as the directory block.
|
||||
|
||||
#define VPK_HEADER_MARKER 0x55aa1234 // significes that this is a new vpk header format
|
||||
#define VPK_CURRENT_VERSION 2
|
||||
#define VPK_PREVIOUS_VERSION 1
|
||||
|
||||
|
||||
struct VPKDirHeader_t
|
||||
{
|
||||
int32 m_nHeaderMarker;
|
||||
int32 m_nVersion;
|
||||
int32 m_nDirectorySize;
|
||||
int32 m_nEmbeddedChunkSize;
|
||||
int32 m_nChunkHashesSize;
|
||||
int32 m_nSelfHashesSize;
|
||||
int32 m_nSignatureSize;
|
||||
|
||||
VPKDirHeader_t( void )
|
||||
{
|
||||
m_nHeaderMarker = VPK_HEADER_MARKER;
|
||||
m_nVersion = VPK_CURRENT_VERSION;
|
||||
m_nDirectorySize = 0;
|
||||
m_nEmbeddedChunkSize = 0;
|
||||
m_nChunkHashesSize = 0;
|
||||
m_nSelfHashesSize = 0;
|
||||
m_nSignatureSize = 0;
|
||||
}
|
||||
|
||||
uint32 ComputeSizeofSignedDataAfterHeader() const
|
||||
{
|
||||
return m_nDirectorySize + m_nEmbeddedChunkSize + m_nChunkHashesSize + m_nSelfHashesSize;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct VPKDirHeaderOld_t
|
||||
{
|
||||
int32 m_nHeaderMarker;
|
||||
int32 m_nVersion;
|
||||
int32 m_nDirectorySize;
|
||||
|
||||
VPKDirHeaderOld_t( void )
|
||||
{
|
||||
m_nHeaderMarker = VPK_HEADER_MARKER;
|
||||
m_nVersion = VPK_PREVIOUS_VERSION;
|
||||
m_nDirectorySize = 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include "vpklib/packedstore.h"
|
||||
|
||||
|
39
vpklib/vpklib.vpc
Normal file
39
vpklib/vpklib.vpc
Normal file
@ -0,0 +1,39 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// VPKLIB.VPC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$Macro SRCDIR ".."
|
||||
|
||||
$Include "$SRCDIR\vpc_scripts\source_lib_base.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
//$PreprocessorDefinitions "$BASE"
|
||||
$AdditionalIncludeDirectories "$BASE;;$SRCDIR/external;$SRCDIR/external/crypto++-5.6.3"
|
||||
}
|
||||
}
|
||||
|
||||
$Project "vpklib"
|
||||
{
|
||||
$Folder "Source Files"
|
||||
{
|
||||
$File "packedstore.cpp"
|
||||
$Folder "Crypto"
|
||||
{
|
||||
$File "$SRCDIR\common\simplebitstring.cpp"
|
||||
}
|
||||
}
|
||||
|
||||
$Folder "Header Files"
|
||||
{
|
||||
$File "$SRCDIR\public\vpklib\packedstore.h"
|
||||
$File "packedstore_internal.h"
|
||||
$Folder "Crypto"
|
||||
{
|
||||
$File "$SRCDIR\common\simplebitstring.h"
|
||||
$File "$SRCDIR\common\crypto.h"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user