diff options
author | Alexei Podtelezhnikov <apodtele@gmail.com> | 2021-09-17 08:31:27 -0400 |
---|---|---|
committer | Alexei Podtelezhnikov <apodtele@gmail.com> | 2021-09-17 08:31:27 -0400 |
commit | 0b429b609c4a5fec8568dc9716e920533e13ab74 (patch) | |
tree | c6535acc1958e7964635c7ad3d1a7ccf2c1483fb /builds | |
parent | 6e1ef98a04e5f8528ffc8f17c6674e5dee9c43ad (diff) | |
download | freetype2-0b429b609c4a5fec8568dc9716e920533e13ab74.tar.gz |
[builds/windows] Try both wide and narrow `CreateFile`
Windows handles wchar_t* UTF-16 and char* ANSI (presently UTF-8)
filenames using alternative -A and -W API. We'll try them both
when opening a file. This means that you should not worry about
about conversions.
Fixes #1098 and !76.
* builds/windows/ftsystem.c (FT_Stream_Open): Call alternative
`CreateFile` in the case of failure.
Diffstat (limited to 'builds')
-rw-r--r-- | builds/windows/ftsystem.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/builds/windows/ftsystem.c b/builds/windows/ftsystem.c index 9a6f0c4b0..69ef494f1 100644 --- a/builds/windows/ftsystem.c +++ b/builds/windows/ftsystem.c @@ -215,9 +215,21 @@ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ); if ( file == INVALID_HANDLE_VALUE ) { - FT_ERROR(( "FT_Stream_Open:" )); - FT_ERROR(( " could not open `%s'\n", filepathname )); - return FT_THROW( Cannot_Open_Resource ); + /* fall back on the alernative interface */ +#ifdef UNICODE + file = CreateFileA( (LPCSTR)filepathname, GENERIC_READ, FILE_SHARE_READ, + NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ); +#else + file = CreateFileW( (LPCWSTR)filepathname, GENERIC_READ, FILE_SHARE_READ, + NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ); +#endif + + if ( file == INVALID_HANDLE_VALUE ) + { + FT_ERROR(( "FT_Stream_Open:" )); + FT_ERROR(( " could not open `%s'\n", filepathname )); + return FT_THROW( Cannot_Open_Resource ); + } } #if defined _WIN32_WCE || defined _WIN32_WINDOWS || \ |