freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [builds/windows] Revert back to `Create


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] [builds/windows] Revert back to `CreateFileA` only.
Date: Wed, 22 Sep 2021 03:23:44 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

1 changed file:

Changes:

  • builds/windows/ftsystem.c
    ... ... @@ -196,6 +196,61 @@
    196 196
       }
    
    197 197
     
    
    198 198
     
    
    199
    +#ifdef _WIN32_WCE
    
    200
    +
    
    201
    +  FT_LOCAL_DEF( HANDLE )
    
    202
    +  CreateFileA( LPCSTR                lpFileName,
    
    203
    +               DWORD                 dwDesiredAccess,
    
    204
    +               DWORD                 dwShareMode,
    
    205
    +               LPSECURITY_ATTRIBUTES lpSecurityAttributes,
    
    206
    +               DWORD                 dwCreationDisposition,
    
    207
    +               DWORD                 dwFlagsAndAttributes,
    
    208
    +               HANDLE                hTemplateFile )
    
    209
    +  {
    
    210
    +    int            len;
    
    211
    +    LPWSTR         lpFileNameW;
    
    212
    +
    
    213
    +
    
    214
    +    /* allocate memory space for converted path name */
    
    215
    +    len = MultiByteToWideChar( CP_ACP, MB_ERR_INVALID_CHARS,
    
    216
    +                               lpFileName, -1, NULL, 0 );
    
    217
    +
    
    218
    +    lpFileNameW = (LPWSTR)_alloca( len * sizeof ( WCHAR ) );
    
    219
    +
    
    220
    +    if ( !len || !lpFileNameW )
    
    221
    +    {
    
    222
    +      FT_ERROR(( "FT_Stream_Open: cannot convert file name to LPWSTR\n" ));
    
    223
    +      return INVALID_HANDLE_VALUE;
    
    224
    +    }
    
    225
    +
    
    226
    +    /* now it is safe to do the translation */
    
    227
    +    MultiByteToWideChar( CP_ACP, MB_ERR_INVALID_CHARS,
    
    228
    +                         lpFileName, -1, lpFileNameW, len );
    
    229
    +
    
    230
    +    /* open the file */
    
    231
    +    return CreateFileW( lpFileNameW, dwDesiredAccess, dwShareMode,
    
    232
    +                        lpSecurityAttributes, dwCreationDisposition,
    
    233
    +                        dwFlagsAndAttributes, hTemplateFile );
    
    234
    +  }
    
    235
    +
    
    236
    +
    
    237
    +  FT_LOCAL_DEF( BOOL )
    
    238
    +  GetFileSizeEx( HANDLE         hFile,
    
    239
    +                 PLARGE_INTEGER lpFileSize )
    
    240
    +  {
    
    241
    +    lpFileSize->u.LowPart = GetFileSize( hFile,
    
    242
    +                                         (DWORD *)&lpFileSize->u.HighPart );
    
    243
    +
    
    244
    +    if ( lpFileSize->u.LowPart == INVALID_FILE_SIZE &&
    
    245
    +         GetLastError() != NO_ERROR                 )
    
    246
    +      return FALSE;
    
    247
    +    else
    
    248
    +      return TRUE;
    
    249
    +  }
    
    250
    +
    
    251
    +#endif /* _WIN32_WCE */
    
    252
    +
    
    253
    +
    
    199 254
       /* documentation is in ftobjs.h */
    
    200 255
     
    
    201 256
       FT_BASE_DEF( FT_Error )
    
    ... ... @@ -211,36 +266,16 @@
    211 266
           return FT_THROW( Invalid_Stream_Handle );
    
    212 267
     
    
    213 268
         /* open the file */
    
    214
    -    file = CreateFile( (LPCTSTR)filepathname, GENERIC_READ, FILE_SHARE_READ,
    
    215
    -                       NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
    
    269
    +    file = CreateFileA( (LPCSTR)filepathname, GENERIC_READ, FILE_SHARE_READ,
    
    270
    +                        NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
    
    216 271
         if ( file == INVALID_HANDLE_VALUE )
    
    217 272
         {
    
    218
    -      /* fall back on the alernative interface */
    
    219
    -#ifdef UNICODE
    
    220
    -      file = CreateFileA( (LPCSTR)filepathname, GENERIC_READ, FILE_SHARE_READ,
    
    221
    -                          NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
    
    222
    -#else
    
    223
    -      file = CreateFileW( (LPCWSTR)filepathname, GENERIC_READ, FILE_SHARE_READ,
    
    224
    -                          NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
    
    225
    -#endif
    
    226
    -
    
    227
    -      if ( file == INVALID_HANDLE_VALUE )
    
    228
    -      {
    
    229
    -        FT_ERROR(( "FT_Stream_Open:" ));
    
    230
    -        FT_ERROR(( " could not open `%s'\n", filepathname ));
    
    231
    -        return FT_THROW( Cannot_Open_Resource );
    
    232
    -      }
    
    273
    +      FT_ERROR(( "FT_Stream_Open:" ));
    
    274
    +      FT_ERROR(( " could not open `%s'\n", filepathname ));
    
    275
    +      return FT_THROW( Cannot_Open_Resource );
    
    233 276
         }
    
    234 277
     
    
    235
    -#if defined _WIN32_WCE || defined _WIN32_WINDOWS || \
    
    236
    -    (defined _WIN32_WINNT && _WIN32_WINNT <= 0x0400)
    
    237
    -    /* Use GetFileSize() for legacy Windows */
    
    238
    -    size.u.LowPart = GetFileSize( file, (DWORD *)&size.u.HighPart );
    
    239
    -    if ( size.u.LowPart == INVALID_FILE_SIZE && GetLastError() != NO_ERROR )
    
    240
    -#else
    
    241
    -    /* Use GetFileSizeEx() for modern Windows */
    
    242 278
         if ( GetFileSizeEx( file, &size ) == FALSE )
    
    243
    -#endif
    
    244 279
         {
    
    245 280
           FT_ERROR(( "FT_Stream_Open:" ));
    
    246 281
           FT_ERROR(( " could not retrieve size of file `%s'\n", filepathname ));
    


  • reply via email to

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