
On Thu, Dec 8, 2011 at 12:29 AM, Dean Michael Berris
On Thu, Dec 8, 2011 at 12:19 AM, Thorsten Ottosen
wrote: Hi,
I'm using file_mapping/mapped_region with Boost 1.45. My idea was to load the memory mapped file in read/write mode and then decrypt the file content in-place (to avoid copying the entire file content). However, this will save a decrypted file :-(
Is there any way to avoid the file being saved after in-memory manipulation?
In POSIX there's a way to say that a read/write region can be declared private -- changes to it would not be propagated to the underlying file. I don't see a way from the docs of providing the MAP_PRIVATE flag to the call to mmap.
Not sure if there's a similar concept in Windows.
Actually, I just checked the docs: it seems you want the 'copy_on_write' mode which combines PROT_WRITE|PROT_READ and MAP_PRIVATE. This allows you to make changes in place to the memory region without having the changes reflected to the original file. HTH Cheers -- Dean Michael Berris http://goo.gl/CKCJX