Fragmentation cannot be avoided.

My idea is to keep a list of unused blocks. And reuse them asap. This gets you fragmention in the end. But for the moment i do not care.

Analyzing if you have fragmented files will be easy. Defragmenting it won't be as you said.

During the day i will upload what i have this far. Just wrote some new code on writing data using tvirtualfilestream into a tvirualfilesystem. But i still need to test that. Writing and reading a complete stream at once already works.