Closed 0HMyC closed 1 year ago
Nevermind, I was just a sleep deprived dumbass who missed this part of the script:
headersDir = os.path.join(input, "Headers")
if os.path.isdir(filesDir):
if os.path.isdir(headersDir):
print("Packing", input, "into CPK file...")
#pack files into cpk
cpkData = packFiles(filesDir, headersDir)
#write file data to disk
with open(outputFolder, "wb") as cpkOut:
cpkOut.write(cpkData)
else:
#TODO: Add ability to generate generic header, if that's even a good idea
print("Warning! Could not locate Headers directory in", headersDir + "! Folder will not be packed into CPK!")
Meaning the script has already been doing this, making this issue completely pointless. Oops.
Currently, the pack.py script doesn't account for the scenario of someone attempting to pack files into a CPK without also providing a .bin file containing the necessary header data for the file in the Headers directory.
(The relevant part of that script:)
The script always assumes that the needed header file exists, and as such attempting to read data from that non-existent file causes an exception that isn't as immediately helpful as a plain-english error.
While it would be possible to make the script force generate a blank header as needed (which would allow the file to pack,) that's a terrible idea because then the resulting .CPK just wouldn't work at all in-game most likely.
Therefore, I feel that the best solution is to simply add a check for whether the file exists, print a simple error message telling the user they need to have a header file at the location the script is attempting to load from, and stop the script early. This prevents potentially faulty output files while making things simpler and easier for the average user with practically no compromise.