winrt: use windowsio in non-libc mode
CMake's SDL_build_config.h force disables HAVE_STDIO_H when buiding winrt in non-libc mode. Becase CreateFileEx is not available in UWP mode, use CreateFile2 instead.main
parent
ea8757a748
commit
b7889a7389
|
@ -107,7 +107,7 @@ typedef struct SDL_RWops
|
||||||
void *asset;
|
void *asset;
|
||||||
} androidio;
|
} androidio;
|
||||||
|
|
||||||
#elif defined(__WIN32__) || defined(__GDK__)
|
#elif defined(__WIN32__) || defined(__GDK__) || defined(__WINRT__)
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
SDL_bool append;
|
SDL_bool append;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
#if defined(__WIN32__) || defined(__GDK__)
|
#if defined(__WIN32__) || defined(__GDK__) || defined(__WINRT__)
|
||||||
#include "../core/windows/SDL_windows.h"
|
#include "../core/windows/SDL_windows.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -47,10 +47,9 @@
|
||||||
#include "../core/android/SDL_android.h"
|
#include "../core/android/SDL_android.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__WIN32__) || defined(__GDK__)
|
#if defined(__WIN32__) || defined(__GDK__) || defined(__WINRT__)
|
||||||
|
|
||||||
/* Functions to read/write Win32 API file pointers */
|
/* Functions to read/write Win32 API file pointers */
|
||||||
|
|
||||||
#ifndef INVALID_SET_FILE_POINTER
|
#ifndef INVALID_SET_FILE_POINTER
|
||||||
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
|
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
|
||||||
#endif
|
#endif
|
||||||
|
@ -59,7 +58,7 @@
|
||||||
|
|
||||||
static int SDLCALL windows_file_open(SDL_RWops *context, const char *filename, const char *mode)
|
static int SDLCALL windows_file_open(SDL_RWops *context, const char *filename, const char *mode)
|
||||||
{
|
{
|
||||||
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) && !defined(__WINRT__)
|
||||||
UINT old_error_mode;
|
UINT old_error_mode;
|
||||||
#endif
|
#endif
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
|
@ -95,7 +94,7 @@ static int SDLCALL windows_file_open(SDL_RWops *context, const char *filename, c
|
||||||
if (!context->hidden.windowsio.buffer.data) {
|
if (!context->hidden.windowsio.buffer.data) {
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
}
|
}
|
||||||
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) && !defined(__WINRT__)
|
||||||
/* Do not open a dialog box if failure */
|
/* Do not open a dialog box if failure */
|
||||||
old_error_mode =
|
old_error_mode =
|
||||||
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
|
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
|
||||||
|
@ -103,14 +102,29 @@ static int SDLCALL windows_file_open(SDL_RWops *context, const char *filename, c
|
||||||
|
|
||||||
{
|
{
|
||||||
LPTSTR tstr = WIN_UTF8ToString(filename);
|
LPTSTR tstr = WIN_UTF8ToString(filename);
|
||||||
h = CreateFile(tstr, (w_right | r_right),
|
#if defined(__WINRT__)
|
||||||
(w_right) ? 0 : FILE_SHARE_READ, NULL,
|
CREATEFILE2_EXTENDED_PARAMETERS extparams;
|
||||||
|
SDL_zero(extparams);
|
||||||
|
extparams.dwSize = sizeof(extparams);
|
||||||
|
extparams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
|
||||||
|
h = CreateFile2(tstr,
|
||||||
|
(w_right | r_right),
|
||||||
|
(w_right) ? 0 : FILE_SHARE_READ,
|
||||||
(must_exist | truncate | a_mode),
|
(must_exist | truncate | a_mode),
|
||||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
&extparams);
|
||||||
|
#else
|
||||||
|
h = CreateFile(tstr,
|
||||||
|
(w_right | r_right),
|
||||||
|
(w_right) ? 0 : FILE_SHARE_READ,
|
||||||
|
NULL,
|
||||||
|
(must_exist | truncate | a_mode),
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
NULL);
|
||||||
|
#endif
|
||||||
SDL_free(tstr);
|
SDL_free(tstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) && !defined(__WINRT__)
|
||||||
/* restore old behavior */
|
/* restore old behavior */
|
||||||
SetErrorMode(old_error_mode);
|
SetErrorMode(old_error_mode);
|
||||||
#endif
|
#endif
|
||||||
|
@ -496,7 +510,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
|
||||||
rwops->close = Android_JNI_FileClose;
|
rwops->close = Android_JNI_FileClose;
|
||||||
rwops->type = SDL_RWOPS_JNIFILE;
|
rwops->type = SDL_RWOPS_JNIFILE;
|
||||||
|
|
||||||
#elif defined(__WIN32__) || defined(__GDK__)
|
#elif defined(__WIN32__) || defined(__GDK__) || defined(__WINRT__)
|
||||||
rwops = SDL_CreateRW();
|
rwops = SDL_CreateRW();
|
||||||
if (rwops == NULL) {
|
if (rwops == NULL) {
|
||||||
return NULL; /* SDL_SetError already setup by SDL_CreateRW() */
|
return NULL; /* SDL_SetError already setup by SDL_CreateRW() */
|
||||||
|
|
Loading…
Reference in New Issue