<stefan.kniep@gmx.de> wrote in message
news:1188331576.738093.80340@o80g2000hse.googlegroups.com...
Thanks again.
Of course you can meet them. You just need to account for alignment
when
you create your buffers, that might mean using VirtualAlloc to make your
array instead of operator new.
Okay, but meeting them would be quite complicated. In my project, I
have to write data blocks of variing size at variing positions in the
file. The code I listed above was just the smallest example that shows
the performance loss I encountered after switching from write to
WriteFile. My impression is that it would take me a lot of time to
switch to unbuffered writing.
Then use a memory mapped file. The pagefile manager takes care of all the
details of reading and writing entire blocks at once, ensuring alignment,
and so forth. You just address whatever part of the file you need using
simple pointer arithmetic. When you close the file (or the file mapping)
or the system needs the RAM for other processes, your changes get
persisted back to the original file using efficient block writes.
up or down) via a file mapping. If you just need random access into a file
performance way to go.