-/*
- * file-mmap-windows.c: MemoryMappedFile internal calls for Windows
+/**
+ * \file
+ * MemoryMappedFile internal calls for Windows
*
* Copyright 2016 Microsoft
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
HANDLE result = NULL;
if (handle == INVALID_HANDLE_VALUE) {
- if (*capacity <= 0) {
+ if (*capacity <= 0 && mode != FILE_MODE_OPEN) {
*error = CAPACITY_MUST_BE_POSITIVE;
return NULL;
}
result = open_handle (hFile, mapName, mode, capacity, access, options, error);
done:
+ if (hFile != INVALID_HANDLE_VALUE)
+ CloseHandle (hFile);
if (!result && delete_on_error)
DeleteFileW (w_path);
if (w_path)