> For writing files, do you have any idea's on how to find > next > available clusters the fastest? > > First I would obviously see if there are any extra clusters > directly > at the end of the file by checking the FAT. But if there > are none > available there, how can I find more fast? I'd rather not > search the > entire fat to find space, but it may have to be like that.
I think that's the usual way... First, of course, check the "non-fragment" cluster, that is the cluster right after the last one occupied by the file in question. If this one is already used, start at the beginning of the FAT, and look at each cluster to see if it's free. That's a disadvantage in the simple design of FAT and is one of the reasons why fragmentation is such an issue with FAT. Other filesystems don't fragment as much as FAT, and even if they do, the performance is not as much affected as with FAT. FAT32, in contrast to FAT12 or FAT16, at least has the number of free clusters stored somewhere in the filesystem header. (That should be updated when a new cluster is used...) On FAT12 or FAT16, just to find out how much space is free on the filesystem, the whole FAT has to be scanned! So, I'm sorry, I have no better idea than doing it that way. You could, If you're presuming that not a very large number of files will be used, look for a free cluster at the beginning of a FAT sector. If you find one, chances are that you will find at least 32 continuous clusters and wouldn't have to search for another free cluster again soon. Another advantage of this procedure is, though you're deliberately introducing "fragmented free space", if there is more than one file growing, you're leaving room for the other files to grow. So the new fragments will usually be at least 32 continuous clusters. If two files grow the same amount in turn, you would otherwise get single cluster fragments, which will soon be unreadable by the current implementation. Greets, Kiste -- You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
