mdbx-windows: use CreateFileW() instead of CreateFileA().

Resolves https://github.com/leo-yuriev/libmdbx/issues/66

Change-Id: I0266a8a77460940332045c19cb561553a5047e7c
This commit is contained in:
Leonid Yuriev
2019-11-04 12:57:44 +03:00
parent fff19d878f
commit b7ed67543f
2 changed files with 20 additions and 15 deletions

View File

@@ -505,6 +505,12 @@ MDBX_INTERNAL_FUNC int mdbx_openfile(const char *pathname, int flags,
*fd = INVALID_HANDLE_VALUE;
#if defined(_WIN32) || defined(_WIN64)
(void)mode;
size_t wlen = mbstowcs(nullptr, pathname, INT_MAX);
if (wlen < 1 || wlen > /* MAX_PATH */ INT16_MAX)
return ERROR_INVALID_NAME;
wchar_t *const pathnameW = _alloca((wlen + 1) * sizeof(wchar_t));
if (wlen != mbstowcs(pathnameW, pathname, wlen + 1))
return ERROR_INVALID_NAME;
DWORD DesiredAccess, ShareMode;
DWORD FlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
@@ -544,7 +550,7 @@ MDBX_INTERNAL_FUNC int mdbx_openfile(const char *pathname, int flags,
break;
}
*fd = CreateFileA(pathname, DesiredAccess, ShareMode, NULL,
*fd = CreateFileW(pathnameW, DesiredAccess, ShareMode, NULL,
CreationDisposition, FlagsAndAttributes, NULL);
if (*fd == INVALID_HANDLE_VALUE)