Create a structure to hold the name of a file, the size, the offset into the file, and the offset to the next structure.
Open the file for writing. Write one structure. Write the bytes of your first image/file/whatever. Reposition the file pointer back to the start of the structure, and re-write the structure with the new info.
Reposition the file pointer to the end of the file (using the offset to the next structure value you wrote in the first structure).
Write the 2nd structure. Write the bytes for the 2nd data file. Reposition the file pointer to the start of the 2nd structure. Rewrite the 2nd structure using the new values.
For the last data file, put a zero value in for the offset to the next structure to indicate it's the last file in the archive.
You can also get fancy by storing a MD-5 hash of the datafile to detect any file corruption, etc. You can also have it span media by putting a flag in the structure to indicate there is more to the file than is in the remainder of the file.
Chip H.
If you want to get the best response to a question, please check out FAQ222-2244 first
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.