vcpkg/ports/libflac/uwp-createfile2.patch

39 lines
1.5 KiB
Diff
Raw Normal View History

2017-11-17 07:54:14 +08:00
diff --git a/src/libFLAC/windows_unicode_filenames.c b/src/libFLAC/windows_unicode_filenames.c
index 2404e31..d320bf5 100644
2017-11-17 07:54:14 +08:00
--- a/src/libFLAC/windows_unicode_filenames.c
+++ b/src/libFLAC/windows_unicode_filenames.c
@@ -185,6 +185,27 @@ int flac_internal_rename_utf8(const char *oldname, const char *newname)
2017-11-17 07:54:14 +08:00
HANDLE WINAPI flac_internal_CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
+#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
2017-11-17 07:54:14 +08:00
+ HANDLE handle = INVALID_HANDLE_VALUE;
+
2017-11-17 07:54:14 +08:00
+ if (!utf8_filenames)
+ return handle;
2017-11-17 07:54:14 +08:00
+
+ wchar_t *wname;
+
+ if ((wname = wchar_from_utf8(lpFileName)) != NULL)
+ {
+ CREATEFILE2_EXTENDED_PARAMETERS cfParams = {0};
+ cfParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ cfParams.dwFileAttributes = dwFlagsAndAttributes & FILE_ATTRIBUTE_NORMAL;
+ cfParams.lpSecurityAttributes = lpSecurityAttributes;
+ cfParams.hTemplateFile = hTemplateFile;
+ handle = CreateFile2(wname, dwDesiredAccess, dwShareMode, dwCreationDisposition, &cfParams);
+ free(wname);
+ }
2017-11-17 07:54:14 +08:00
+
+ return handle;
+#else
if (!utf8_filenames) {
return CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
} else {
@@ -198,4 +219,5 @@ HANDLE WINAPI flac_internal_CreateFile_utf8(const char *lpFileName, DWORD dwDesi
return handle;
}
+#endif
2017-11-17 07:54:14 +08:00
}