1 diff --git a/src/share/win_utf8_io/win_utf8_io.c b/src/share/win_utf8_io/win_utf8_io.c
2 index 8b20bbb7..058295fa 100644
3 --- a/src/share/win_utf8_io/win_utf8_io.c
4 +++ b/src/share/win_utf8_io/win_utf8_io.c
5 @@ -156,6 +156,27 @@ int get_utf8_argv(int *argc, char ***argv)
6 /* similar to CreateFileW but accepts UTF-8 encoded lpFileName */
7 HANDLE WINAPI CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
9 +#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
10 + HANDLE handle = INVALID_HANDLE_VALUE;
12 + if (!flac_internal_get_utf8_filenames())
17 + if ((wname = wchar_from_utf8(lpFileName)) != NULL)
19 + CREATEFILE2_EXTENDED_PARAMETERS cfParams = {0};
20 + cfParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
21 + cfParams.dwFileAttributes = dwFlagsAndAttributes & FILE_ATTRIBUTE_NORMAL;
22 + cfParams.lpSecurityAttributes = lpSecurityAttributes;
23 + cfParams.hTemplateFile = hTemplateFile;
24 + handle = CreateFile2(wname, dwDesiredAccess, dwShareMode, dwCreationDisposition, &cfParams);
30 if (!flac_internal_get_utf8_filenames()) {
31 return CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
33 @@ -169,6 +190,7 @@ HANDLE WINAPI CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWO
40 /* return number of characters in the UTF-8 string */