freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master 0574692c6 1/2: [build/windows] Improve UWP support.


From: Werner Lemberg
Subject: [freetype2] master 0574692c6 1/2: [build/windows] Improve UWP support.
Date: Wed, 23 Mar 2022 22:56:24 -0400 (EDT)

branch: master
commit 0574692c6db873c7782cfee68cef504300e608e1
Author: Steve Lhomme <robux4@ycbcr.xyz>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    [build/windows] Improve UWP support.
    
    * builds/windows/ftsystem.c [UWP]: Wrap CreateFile2 into CreateFileA.
---
 builds/windows/ftsystem.c | 50 +++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 44 insertions(+), 6 deletions(-)

diff --git a/builds/windows/ftsystem.c b/builds/windows/ftsystem.c
index d4fc95675..34d7c2cbf 100644
--- a/builds/windows/ftsystem.c
+++ b/builds/windows/ftsystem.c
@@ -196,25 +196,63 @@
   }
 
 
-#if defined( NTDDI_VERSION ) && NTDDI_VERSION < 0x0A000007 && \
-    defined( WINAPI_FAMILY_PARTITION )                 &&     \
+  /* non-desktop Universal Windows Platform */
+#if defined( WINAPI_FAMILY_PARTITION )                 &&     \
     !WINAPI_FAMILY_PARTITION( WINAPI_PARTITION_DESKTOP )
 
 #define PACK_DWORD64( hi, lo )  ( ( (DWORD64)(hi) << 32 ) | (DWORD)(lo) )
 
-#define CreateFileW( a, b, c, d, e, f, g ) \
-        CreateFileFromAppW( a, b, c, d, e, f, g )
 #define CreateFileMapping( a, b, c, d, e, f ) \
         CreateFileMappingFromApp( a, b, c, PACK_DWORD64( d, e ), f )
 #define MapViewOfFile( a, b, c, d, e ) \
         MapViewOfFileFromApp( a, b, PACK_DWORD64( c, d ), e )
 
-#define UWP_LEGACY
+  FT_LOCAL_DEF( HANDLE )
+  CreateFileA( LPCSTR                lpFileName,
+               DWORD                 dwDesiredAccess,
+               DWORD                 dwShareMode,
+               LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+               DWORD                 dwCreationDisposition,
+               DWORD                 dwFlagsAndAttributes,
+               HANDLE                hTemplateFile )
+  {
+    int            len;
+    LPWSTR         lpFileNameW;
+
+    CREATEFILE2_EXTENDED_PARAMETERS  createExParams = {
+                               sizeof ( CREATEFILE2_EXTENDED_PARAMETERS ),
+                               dwFlagsAndAttributes & 0x0000FFFF,
+                               dwFlagsAndAttributes & 0xFFF00000,
+                               dwFlagsAndAttributes & 0x000F0000,
+                               lpSecurityAttributes,
+                               hTemplateFile };
+
+
+    /* allocate memory space for converted path name */
+    len = MultiByteToWideChar( CP_ACP, MB_ERR_INVALID_CHARS,
+                               lpFileName, -1, NULL, 0 );
+
+    lpFileNameW = (LPWSTR)_alloca( len * sizeof ( WCHAR ) );
+
+    if ( !len || !lpFileNameW )
+    {
+      FT_ERROR(( "FT_Stream_Open: cannot convert file name to LPWSTR\n" ));
+      return INVALID_HANDLE_VALUE;
+    }
+
+    /* now it is safe to do the translation */
+    MultiByteToWideChar( CP_ACP, MB_ERR_INVALID_CHARS,
+                         lpFileName, -1, lpFileNameW, len );
+
+    /* open the file */
+    return CreateFile2( lpFileNameW, dwDesiredAccess, dwShareMode,
+                        dwCreationDisposition, &createExParams );
+  }
 
 #endif
 
 
-#if defined( _WIN32_WCE ) || defined( UWP_LEGACY )
+#if defined( _WIN32_WCE )
 
   FT_LOCAL_DEF( HANDLE )
   CreateFileA( LPCSTR                lpFileName,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]