For a file vault application, GMBinaryFile has a file insertion system
Add file to fault
hf = GMBINOpenFileWrite(filename);
GMBINInsertFile(hf, "image1.png");
GMBINInsertFile(hf, "image2.png");
GMBINInsertFile(hf, "image3.png");
GMBINCloseFile(hf);
extract file from vault
hf = GMBINOpenFileRead(filename);
GMBINExtractFile(hf, "image1.png");
GMBINExtractFile(hf, "image2.png");
GMBINExtractFile(hf, "image3.png");
GMBINCloseFile(hf);
of course you would want to make it smart enough to know what the file name was. you can mix the insertion with all the extra information you need
hf = GMBINOpenFileWrite(destfilename);
GMBINWriteInt(hf,numberoffiles)
i = 0;
repeat(numberoffiles)
{
GMBINWriteString(hf,filename[i]);
GMBINInsertFile(hf, filename[i]);
i+=1;
}
GMBINCloseFile(hf);
hf = GMBINOpenFileRead(filename);
numberoffiles = GMBINReadInt(hf)
i = 0;
repeat(numberoffiles)
{
filename[i] = GMBINReadString(hf);
GMBINExtractFile(hf, filename[i]);
i+=1;
}
GMBINCloseFile(hf);
where filename[] is the array of files and numberoffiles is the size of the array.
as for the chunk method, though the file insert trumps that, it would be
hdest = GMBINOpenFileWrite(destfilename);
for each file to insert, set sourcefilename
{
hsrc = GMBINOpenFileWrite(sourcefilename);
while(!GMBINIsEOF(hsrc))
{
data = GMBINReadBuffer(hsrc,SIZE);
GMBINWriteBuffer(hdest,data,SIZE);
}
GMBINCloseFile(hsrc);
}
GMBINCloseFile(hdest);
where SIZE is 1024 (1k), 2048(2k), 4096(4k) and so on. you would have to test which size is optimal. I did omit the end of the file where the size of the read would be less that the size left. You would need to track what you read vs what is left and adjust the size for the last read/write