bug fix: close() only unmapViewOfFile() when fHandle is valid.

Added extra test on windows close so if already closed it
doesn't throw an exception.
This commit is contained in:
JamesP 2015-09-12 14:41:50 +10:00
commit 88fc415c69

View file

@ -226,7 +226,7 @@ proc close*(f: var MemFile) =
var lastErr: OSErrorCode var lastErr: OSErrorCode
when defined(windows): when defined(windows):
if f.fHandle != INVALID_HANDLE_VALUE: if f.fHandle != INVALID_HANDLE_VALUE and f.fHandle != 0:
error = unmapViewOfFile(f.mem) == 0 error = unmapViewOfFile(f.mem) == 0
lastErr = osLastError() lastErr = osLastError()
error = (closeHandle(f.mapHandle) == 0) or error error = (closeHandle(f.mapHandle) == 0) or error