logoalt Hacker News

cmovqtoday at 12:43 AM3 repliesview on HN

> Perhaps surprisingly, the ZIP file puts the central directory - which lists the content of the ZIP file - at the end of the file

This is very common for archive files. It lets you easily append a file to the end of the archive (overwriting the directory) followed by the updated directory. If it were at the start, you’d have to rewrite the entire contents of the archive to grow the directory.


Replies

ahefnertoday at 4:00 AM

Do you really need a central directory? The tar and cpio file formats basically append files serially with a small header preceeding each one, and for most use cases this is sufficient.

show 1 reply
yjftsjthsd-htoday at 1:12 AM

I always assumed you could work around this by pre-allocating a large enough header space to hold a reasonable sized directory tree. You could even then append a supplementary directory if you run out of space and just stick a pointer in the first one. I'm pretty sure that's just reinventing an actual filesystem, but if it works...

show 3 replies
LoganDarktoday at 2:31 AM

I'm curious, is there a reason why you can't incrementally prepend to files? I haven't seen a filesystem that allows prepending to a file without rewriting the entire file. Is it just because it's not traditional, or is there any particular technical reason why it would be too expensive, or etc?

show 3 replies