This repository is a small way on how to pack folders into pbo files. This Python script is implemented with TDD. Also we are frickling around with ctypes, many bytearrays and pretty low-level-file-system-style topics. Was pretty fun to implement it!
"Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)" https://creativecommons.org/licenses/by-sa/4.0/
You must know the principles of TDD and be skilled in python programming.
This project is written with the TDD principles. So the tests are found in the tests
folder. A great way on how to run them is via any IDE where my favorite choice is PyCharm (Professional).
The production code is found in the src folder where an python module is placed which has the same name as the project.
The Head-, Body- and Footblock are seperated by a 0-byte.
All .pbo files are beginning with an
arma3pbo/src/arma3pbo/pbo/pbo_head.py
Line 9 in a57ccc2
After then, all the so-called
pboprefix
es are added. This happens by adding the following bytes: arma3pbo/src/arma3pbo/pbo/pbo_head.py
Lines 13 to 19 in a57ccc2
These Prefixes are optional and are only added if a file
$<filename>$
with content lies in the project root of the folder.Lastly the pbofile must know what files with what metadata is found in the project structure. A great source for that was the wiki from BI (https://community.bistudio.com/wiki/PBO_File_Format). An Entry is added with the following code:
arma3pbo/src/arma3pbo/pbo/pbo_head.py
Lines 21 to 44 in a57ccc2
Important to know is that all the numbers are saved in little endian
uint32
This part is easy. Here all the files from the project are added with their contents. Its possible to compress these files, but its not really necesarry anymore. Arma 3 was written nearly 1,5 decaded ago where network speed and optimizing attempts were valued higher than performance. Nowadays this isn't really a problem anymore and in addition to that the engine must decompress the whole thing which may slightly decrese performance.
The only important thing here is that the bytecode of the files are in the same order as in the header-entrys. I am just looping twice over the file array here.
The last 20 bytes are an SHA1 Hash-Value based on the preceding bytes.
arma3pbo/src/arma3pbo/pbo/pbo_foot.py
Lines 5 to 7 in a57ccc2
This packs a folder to a pbo file:
python3 src/arma3pbo/main.py build -i <input-folder> -o <output-file>