Your design looks good to me, though I assume that you meant 32 bits for size rather than 32 bytes!
I think that your design would be best for situations where you want to load up all your assets in one go, because it's kind of a sequential design. If you want to load up just a few assets at a time (maybe because each game level uses only a subset of the assets) then it would be somewhat less efficient, because you would have to read through each asset in turn to find the ones that you want.
In that case you might want to try a more indexed design, maybe something like this:
[HEADER]
[Miscellaneous header stuff]
[Offset to index from start of file]
[Number of entries in index]
[RECORD 1]
[Asset data]
[RECORD 2]
[Asset data]
.
.
[RECORD N]
[Asset data]
[INDEX]
[ID or filename of asset 1]
[Size of asset 1]
[Offset to asset 1 from start of file]
[Other asset 1 flags or whatever]
[ID or filename of asset 2]
[Size of asset 2]
[Offset to asset 2 from start of file]
[Other asset 2 flags or whatever]
.
.
This would allow for better random access of assets, because now you just have to search through your index (which you would load into memory) rather than through your whole file (which might not fit into memory). If you wanted to get fancy you could use a tree or hashtable for the index.
The reason for putting the index at the end of the file rather than the front is that it makes it easier to add another asset to your pack file without having to rebuild the whole thing. Otherwise, the extra entry in your index would throw out all your offsets.
EDIT: to respond to comments...
What I had in mind was that you would only access the assets via the index, so hopefully you would never run off the end of the assets when reading them. Perhaps an example of a typical use case would help.
Say you wanted to read in the texture called "TankTexture.png". Here is how I think that you would go about it:
- Open the pack file.
- Read in the fixed-size header.
- Extract the index offset and number of entries from the header.
- Seek to the start of the index.
- Read the index into an array (fixed index entry size times number of entries).
- Search through the index for the asset called "TankTexture.png".
- Extract the asset offset and size from the index entry.
- Seek to the start of the asset.
- Read in the number of bytes given by the asset size.
Of course, for subsequent assets you would need only steps 6-9.
I hope that helps to explain what I was thinking. Let me know if you have any other questions.