fopen_s(&pFile, "updater_lua.package", "rb");
if (pFile == NULL)
{
printf("Could not open package file.\n");
}
else
{
byte *Pack;
long pSize = 0;
pSize = getFileSize(pFile); //Get the size of the file you just opened.
Pack = new BYTE[pSize]; //size the array to the size of the file
pHeader = new BYTE[sizeof(PackHeader)]; //size the array for the header
fread(pHeader, sizeof(PackHeader), 1, pFile); //read the first 19 bytes to header struct.
memcpy(&cPackHeader, pHeader, sizeof(PackHeader)); //copy the bytes into the struct.
int fStart = sizeof(PackHeader); //set the file position after the header
for(int i = 0; i < cPackHeader.FileCount; i++) //loop the amount of files
{
tpFile = new BYTE[sizeof(PackFile)]; //create new array for the file info
fseek(pFile, fStart, SEEK_SET); //read to the location of the file info
fread(tpFile, sizeof(PackFile), 1, pFile); //copy it to memory
memcpy(&cPackFile, tpFile, sizeof(PackFile)); //copy the data to the PackFile
fStart += cPackFile.DataLength; //add by the size of the file data length
printf("Offset: %I64d FileSize: %i FilePath: %s\n", cPackFile.FileOffset, cPackFile.FileRawSize, cPackFile.FilePath);
}
fclose(pFile);
}