www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - std.MmFile.Mode.readCopyOnWrite documentation/implementation

reply Bastiaan Veelo <Bastiaan Veelo.net> writes:
Currently[1], std.MmFile.Mode.readCopyOnWrite is documented as

 readCopyOnWrite, /// Read/Write existing file, copy on write
When I test that on Windows, what seems to happen is that when written to, memory is copied and the copy is no longer backed by a file. So changes are not persistent and I think this should be clarified in the documentation. This mode will not change the file, and Read/Write should actually be Read, I would think. But marking the file read-only will cause this to fail, as the file is actually opened Read/Write in the implementation, and I wonder whether it should be opened read-only instead. The implementation is platform-specific, so what works on one might not work on the other. Any input on this? Bastiaan. [1] https://github.com/dlang/phobos/blob/841541fca9c8c0224f3d47ef11db219a9fa5e065/std/mmfile.d#L64
Jun 03 2019
parent Jonathan Marler <johnnymarler gmail.com> writes:
On Monday, 3 June 2019 at 09:11:41 UTC, Bastiaan Veelo wrote:
 Currently[1], std.MmFile.Mode.readCopyOnWrite is documented as

 readCopyOnWrite, /// Read/Write existing file, copy on write
When I test that on Windows, what seems to happen is that when written to, memory is copied and the copy is no longer backed by a file. So changes are not persistent and I think this should be clarified in the documentation. This mode will not change the file, and Read/Write should actually be Read, I would think. But marking the file read-only will cause this to fail, as the file is actually opened Read/Write in the implementation, and I wonder whether it should be opened read-only instead. The implementation is platform-specific, so what works on one might not work on the other. Any input on this? Bastiaan. [1] https://github.com/dlang/phobos/blob/841541fca9c8c0224f3d47ef11db219a9fa5e065/std/mmfile.d#L64
It's funny because the name of the enum makes more sense than the comment :) readCopyOnWrite is pretty clear, but "Read/Write existing file, copy on write" is a bit confusing.
Jun 03 2019