|
explicit mmap_file_iterator(std::string const& fileName) |
CreateFileA call uses FILE_SHARE_READ as sharing mode. This makes this call fail, when the file is already open for writing, as explained at https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#parameters (see dwShareMode).
To allow opening files for reading, even when another process has it open for writing, but explicitly allowed reading using its own FILE_SHARE_READ, this call needs to use FILE_SHARE_READ | FILE_SHARE_WRITE (and maybe even also | FILE_SHARE_DELETE).
https://bugs.documentfoundation.org/show_bug.cgi?id=158442 was caused by this problem (fixed by patching spirit).