hi all,

i'm trying to use a memory mapped file....

i would need some help about how to update the file on disk after i've wrote into memory...

i do a memory copy at the end of mapped file of x bytes, then i do FlushViewOfFile, StartingAddress, x bytes
then i unmap the file

but this don't update my file on the disk :(

If someone could help me about this.... thx
Posted on 2002-06-25 16:42:12 by Bit7
Make sure you don't map the file with COPY parameters, e.g. CreateFileMapping with PAGE_READWRITE and MapViewOfFile with FILE_MAP_WRITE. As Win32 API documentation clearly states:
FILE_MAP_COPY - Copy on write access. If you create the map with PAGE_WRITECOPY and the view with FILE_MAP_COPY, you will receive a view to file. If you write to it, the pages are automatically swappable and the modifications you make will not go to the original data file.
Posted on 2002-06-25 22:45:21 by comrade

many thanks for your help.

actually i'm using FILE_MAP_ALL_ACCESS in MapViewOfFile.

Maybe the issue could be:

When i do CreateFileMapping, i set dwMaximumSizeLow to the size of the file. Probably this is the reason that don't let me make the file bigger after writing memory after the end of mapping.
But i set the maximum size as filesize couse seems that if i set it bigger, my file reach immediately this size, also if i don't have already filled it in memory.

Thanks B7
Posted on 2002-06-26 01:39:08 by Bit7
Filemapping doesn't allow you to grow filesize dynamically. Either
you grow the file all at once (as you've noticed yourself), or you
don't grow it at all. Sad, but that's how it is.
Posted on 2002-06-27 13:29:06 by f0dder