(no title)
thasso
|
9 months ago
For archive formats, or anything that has a table of contents or an index, consider putting the index at the end of the file so that you can append to it without moving a lot of data around. This also allows for easy concatenation.
zzo38computer|9 months ago
HelloNurse|9 months ago
charcircuit|9 months ago
>This also allows for easy concatenation.
How would it be easier than putting it at the front?
shakna|9 months ago
So if you rewrite an index at the head of the file, you may end up having to rewrite everything that comes afterwards, to push it further down in the file, if it overflows any padding offset. Which makes appending an extremely slow operation.
Whereas seeking to end, and then rewinding, is not nearly as costly.
lifthrasiir|9 months ago
MattPalmer1086|9 months ago
Reading the index from the end of the file is also quick; where you read next depends on what you are trying to find in it, which may not be the start.
McGlockenshire|9 months ago
Have you ever wondered why `tar` is the Tape Archive? Tape. Magnetic recording tape. You stream data to it, and rewinding is Hard, so you put the list of files you just dealt with at the very end. This now-obsolete hardware expectation touches us decades later.