[PATCH] D54995: [MemoryBuffer] By default assume that all files are volatile to prevent unintended file locks
Ivan Donchevskii via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 29 01:26:05 PST 2018
yvvan added a comment.
According to https://msdn.microsoft.com/en-us/2e9c3174-af48-4fa3-9f6a-fb62b23ed994 - "Unmapping a mapped view of a file invalidates the range occupied by the view in the address space of the process and makes the range available for other allocations".
Also as far as i understand from https://msdn.microsoft.com/en-us/library/ms810613.aspx mapped files can only be edited in other apps as mapped files opened with the same name (OpenFileMapping).
Simple example, I launch it and until i enter the number the test.h header remains locked and therefore i can't edit it in other apps.
DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
int accessRights = 0;
accessRights |= GENERIC_READ;
SECURITY_ATTRIBUTES securityAtts = { sizeof(SECURITY_ATTRIBUTES), NULL, FALSE };
HANDLE fileHandle =
CreateFile("D:\\test.h", accessRights, shareMode, &securityAtts,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
NULL);
HANDLE FileMappingHandle =
CreateFileMappingA(fileHandle, 0, PAGE_READONLY, 0, 0, "D:_code_test.h");
LPVOID Mapping = MapViewOfFile(FileMappingHandle, FILE_MAP_READ, 0, 0, 0);
assert(Mapping);
CloseHandle(FileMappingHandle);
int i {0};
std::cin >> i;
UnmapViewOfFile(Mapping);
CloseHandle(fileHandle);
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54995/new/
https://reviews.llvm.org/D54995
More information about the cfe-commits
mailing list