summaryrefslogtreecommitdiff
path: root/vpklib/mktestpak.pl
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /vpklib/mktestpak.pl
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'vpklib/mktestpak.pl')
-rw-r--r--vpklib/mktestpak.pl43
1 files changed, 43 insertions, 0 deletions
diff --git a/vpklib/mktestpak.pl b/vpklib/mktestpak.pl
new file mode 100644
index 0000000..192e03c
--- /dev/null
+++ b/vpklib/mktestpak.pl
@@ -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;