Memory mapped QFile usage questions



  • 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:

    • seek to 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:

    1. Is it faster to map the whole file once, or map / unmap each location?
    2. Do I need to take special actions for the change to be actually written on disk? Will flush suffice, or do I have to unmap?


  • 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 call unamp and flush in 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)?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.