Memory mapped QFile usage questions
General and Desktop
2
Posts
1
Posters
1.0k
Views
1
Watching
-
I have a pretty large file (hundreds megabytes). I have a list of thousands (possibly even hundreds thousand) locations in this file where I need to patch 4 bytes. Specific algorithm:
seekto a position;- overwrite 4 bytes;
- run and external tool on this file;
- revert these 4 bytes to the original value and proceed to the next location.
Questions:
- Is it faster to map the whole file once, or
map/unmapeach location? - Do I need to take special actions for the change to be actually written on disk? Will
flushsuffice, or do I have tounmap?
-
Turns out speed is not a concern, I started by trying
map->unmap->flush- it's fast,
I've also noticed that I don't need to callunampandflushin order for the changes to be visible to other software. Is that just a coincidence, or is it guaranteed to work (this is a Windows only program)?