jeffb.bbs@shark.cs.fau.edu (Jeffrey Boser) (05/07/91)
With the limitations of the resource fork, and the expense of the Hunk Manager, has anybody come up with a simple way of storing variable-length data items in the data fork? I have come up with a few ideas: A map in the beginning of the file, containing offsets of the chunks, which consist of the size, an identifier, and the data... the problem I see here is the limitations imposed by the map, if your map size is fixed, so is the number of chunks, if it isnt, you have to keep track of the map size and deal with it if it gets too big or too small. Or, a map can be generated upon opening a file, but this may take some time. Another problem is optimizing disk space, moving a chunk up and down the fork to close gaps. ie.. if the map gets smaller, everything after it would have to be moved up. This is not a bad thing, but if there is no map in the beginning, the order can't be changed (if they are identified by number). any thoughts? .....jeff jeffb.bbs@shark.cs.fau.edu "Make something an idiot can use, and only an idiot will use it" -RAH Like a Bible, maybe?
lippin@twinkies.berkeley.edu (The Apathist) (05/07/91)
Recently jeffb.bbs@shark.cs.fau.edu (Jeffrey Boser) wrote: >With the limitations of the resource fork, and the expense of the >Hunk Manager, has anybody come up with a simple way of storing >variable-length data items in the data fork? To my knowledge, no one has come up with a generally useful answer to this question. I think the reason is that the way your program uses the file is strongly reflected in the efficiency of the various methods. In general, make the file structure match the way you use it. If you have a collection of independent things, a single global map is generally a good idea. If the items in the file have some structure, you'll do well to mirror the structure in your file format. If the items split into fixed-size groups, you'll likely want to manage each size individually. As you know less about the contents, the problem becomes more akin to heap management, and most elementary CS books will tell you six different ways to manage a heap. The difference to keep in mind is that a file isn't as close to random-access as a heap -- a free space map will work much more quickly than a linked list of free blocks. --Tom Lippincott lippin@math.berkeley.edu "It's a poor sort of memory that only works backwards." --Lewis Caroll