mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-30 22:47:16 +08:00
mdbx-windows: use CreateFileW() instead of CreateFileA().
Resolves https://github.com/leo-yuriev/libmdbx/issues/66 Change-Id: I0266a8a77460940332045c19cb561553a5047e7c
This commit is contained in:
parent
fff19d878f
commit
b7ed67543f
15
mdbx.h
15
mdbx.h
@ -1458,7 +1458,7 @@ LIBMDBX_API int mdbx_env_create(MDBX_env **penv);
|
||||
* called later to discard the MDBX_env handle and release associated resources.
|
||||
*
|
||||
* [in] env An environment handle returned by mdbx_env_create()
|
||||
* [in] path The directory in which the database files reside.
|
||||
* [in] pathname The directory in which the database files reside.
|
||||
* This directory must already exist and be writable.
|
||||
* [in] flags Special options for this environment. This parameter
|
||||
* must be set to 0 or by bitwise OR'ing together one
|
||||
@ -1514,8 +1514,8 @@ LIBMDBX_API int mdbx_env_create(MDBX_env **penv);
|
||||
* after a system crash.
|
||||
* - MDBX_TOO_LARGE = Database is too large for this process, i.e.
|
||||
* 32-bit process tries to open >4Gb database. */
|
||||
LIBMDBX_API int mdbx_env_open(MDBX_env *env, const char *path, unsigned flags,
|
||||
mode_t mode);
|
||||
LIBMDBX_API int mdbx_env_open(MDBX_env *env, const char *pathname,
|
||||
unsigned flags, mode_t mode);
|
||||
|
||||
/* Copy an MDBX environment to the specified path, with options.
|
||||
*
|
||||
@ -1527,7 +1527,7 @@ LIBMDBX_API int mdbx_env_open(MDBX_env *env, const char *path, unsigned flags,
|
||||
*
|
||||
* [in] env An environment handle returned by mdbx_env_create(). It must
|
||||
* have already been opened successfully.
|
||||
* [in] path The directory in which the copy will reside. This directory
|
||||
* [in] dest The directory in which the copy will reside. This directory
|
||||
* must already exist and be writable but must otherwise be empty.
|
||||
* [in] flags Special options for this operation. This parameter must be set
|
||||
* to 0 or by bitwise OR'ing together one or more of the values
|
||||
@ -1540,8 +1540,7 @@ LIBMDBX_API int mdbx_env_open(MDBX_env *env, const char *path, unsigned flags,
|
||||
* account skipping free pages.
|
||||
*
|
||||
* Returns A non-zero error value on failure and 0 on success. */
|
||||
LIBMDBX_API int mdbx_env_copy(MDBX_env *env, const char *dest_path,
|
||||
unsigned flags);
|
||||
LIBMDBX_API int mdbx_env_copy(MDBX_env *env, const char *dest, unsigned flags);
|
||||
|
||||
/* Copy an MDBX environment to the specified file descriptor,
|
||||
* with options.
|
||||
@ -1821,14 +1820,14 @@ LIBMDBX_API int mdbx_env_get_flags(MDBX_env *env, unsigned *flags);
|
||||
/* Return the path that was used in mdbx_env_open().
|
||||
*
|
||||
* [in] env An environment handle returned by mdbx_env_create()
|
||||
* [out] path Address of a string pointer to contain the path.
|
||||
* [out] dest Address of a string pointer to contain the path.
|
||||
* This is the actual string in the environment, not a copy.
|
||||
* It should not be altered in any way.
|
||||
*
|
||||
* Returns A non-zero error value on failure and 0 on success, some
|
||||
* possible errors are:
|
||||
* - MDBX_EINVAL = an invalid parameter was specified. */
|
||||
LIBMDBX_API int mdbx_env_get_path(MDBX_env *env, const char **path);
|
||||
LIBMDBX_API int mdbx_env_get_path(MDBX_env *env, const char **dest);
|
||||
|
||||
/* Return the file descriptor for the given environment.
|
||||
*
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user