Re: writeable file mapping
- From: "Ben Voigt" <rbv@xxxxxxxxxxxxx>
- Date: Fri, 12 May 2006 13:34:55 -0500
"William DePalo [MVP VC++]" <willd.no.spam@xxxxxxxx> wrote in message
news:%23JTSExedGHA.4276@xxxxxxxxxxxxxxxxxxxxxxx
"Henry Townsend" <henry.townsend@xxxxxxxx> wrote in message
news:vZidnfEUectVXvnZRVn-jg@xxxxxxxxxxxxxx
I'm trying to do something which should be basic but doesn't seem to be
documented. I need to map a file into memory and be able to modify the
mapping while being sure I don't modify the file itself. On Unix this is
done by setting mmap flags = MAP_PRIVATE. On Windows there seems no
documented way to do it. ...I probably won't have write access to the
files and I certainly don't want to risk modifying them even if I do.
This doesn't sound like a need for file-mapping at all, since: (1) you are
not writing to the file using a pointer and (2) you are not expecting other
users' changes to automatically appear (since you want copy-on-write). So,
just do a bulk read from the file into private process memory allocated from
the heap.
Or are you trying to affect the data retrieved by file i/o apis called
elsewhere in your process?
There are at least two possibilities.
The first is that you don't specify a file. If you use
INVALID_HANDLE_VALUE the section will be backed by the paging file. Then
read your file into the mapped section. Of course, there'd be a small
window between its creation and the time when the section has good data.
The second is that you copy the file to another one first.
Regards,
Will
.
- Follow-Ups:
- Re: writeable file mapping
- From: Henry Townsend
- Re: writeable file mapping
- References:
- Re: writeable file mapping
- From: William DePalo [MVP VC++]
- Re: writeable file mapping
- Prev by Date: Re: GetCurrentProcessorNumber() for XP?
- Next by Date: Re: writeable file mapping
- Previous by thread: Re: writeable file mapping
- Next by thread: Re: writeable file mapping
- Index(es):
Relevant Pages
|