Boost logo

Boost Users :

Subject: Re: [Boost-users] [Interprocess] [file_mapping] is there any way to avoid writing a modified file to disc?
From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2011-12-07 08:44:38


On Thu, Dec 8, 2011 at 12:29 AM, Dean Michael Berris
<mikhailberis_at_[hidden]> wrote:
> On Thu, Dec 8, 2011 at 12:19 AM, Thorsten Ottosen
> <thorsten.ottosen_at_[hidden]> 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

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net