Hi,
Im after some advice on how to design a very simple 'file system', specifically a format for a file to contain other files. Think of a zip file with no compression.
So i have a base file of constant x size, that can contain x number of other files within it. These files can be added or deleted.
Now my main problem here is fragmentation. My current design has a main file header, which keeps track of the number of files and total volume size, checksums etc.
Then each file has a 'node' data structure, containing file size, name and offset within the container. So by finding a files node I now know where the file is within the container, and can extract it or delete it.
This in theory will work fine, but say i have 1000 files within the container and delete 200, the result will be a mess and inserting new files will not be easy.
The best thing i can think of is to position files sequentially after a delete operation, this way new files can be inserted onto the end with ease. But moving and repositioning all the files when one is deleted wont be nice on performance.
Can anyone give me some pointers on the best way to approach this? I really want to keep things as simple as possible, it will eventually be inplemented with C.
The Zip file format is like this:
That is perfect for me, but how does it avoid fragmentation if files are deleted?
Thanks,
Jack
Im after some advice on how to design a very simple 'file system', specifically a format for a file to contain other files. Think of a zip file with no compression.
So i have a base file of constant x size, that can contain x number of other files within it. These files can be added or deleted.
Now my main problem here is fragmentation. My current design has a main file header, which keeps track of the number of files and total volume size, checksums etc.
Then each file has a 'node' data structure, containing file size, name and offset within the container. So by finding a files node I now know where the file is within the container, and can extract it or delete it.
This in theory will work fine, but say i have 1000 files within the container and delete 200, the result will be a mess and inserting new files will not be easy.
The best thing i can think of is to position files sequentially after a delete operation, this way new files can be inserted onto the end with ease. But moving and repositioning all the files when one is deleted wont be nice on performance.
Can anyone give me some pointers on the best way to approach this? I really want to keep things as simple as possible, it will eventually be inplemented with C.
The Zip file format is like this:

That is perfect for me, but how does it avoid fragmentation if files are deleted?
Thanks,
Jack
Last edited: