src/file/SDL_rwops.c
changeset 5090 327f181542f1
parent 5086 c2539ff054c8
child 5262 b530ef003506
     1.1 --- a/src/file/SDL_rwops.c	Mon Jan 24 17:47:18 2011 -0800
     1.2 +++ b/src/file/SDL_rwops.c	Mon Jan 24 21:20:30 2011 -0800
     1.3 @@ -44,8 +44,7 @@
     1.4     faster, and all stdio functions anyway are embedded in coredll.dll - 
     1.5     the main wince dll*/
     1.6  
     1.7 -#define WINDOWS_LEAN_AND_MEAN
     1.8 -#include <windows.h>
     1.9 +#include "../core/windows/SDL_windows.h"
    1.10  
    1.11  #ifndef INVALID_SET_FILE_POINTER
    1.12  #define INVALID_SET_FILE_POINTER 0xFFFFFFFF
    1.13 @@ -98,34 +97,28 @@
    1.14      }
    1.15  #ifdef _WIN32_WCE
    1.16      {
    1.17 -        size_t size = SDL_strlen(filename) + 1;
    1.18 -        wchar_t *filenameW = SDL_stack_alloc(wchar_t, size);
    1.19 -
    1.20 -        if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, size) ==
    1.21 -            0) {
    1.22 -            SDL_stack_free(filenameW);
    1.23 -            SDL_free(context->hidden.windowsio.buffer.data);
    1.24 -            context->hidden.windowsio.buffer.data = NULL;
    1.25 -            SDL_SetError("Unable to convert filename to Unicode");
    1.26 -            return -1;
    1.27 -        }
    1.28 -        h = CreateFile(filenameW, (w_right | r_right),
    1.29 +        LPTSTR tstr = WIN_UTF8ToString(filename);
    1.30 +        h = CreateFile(tstr, (w_right | r_right),
    1.31                         (w_right) ? 0 : FILE_SHARE_READ, NULL,
    1.32                         (must_exist | truncate | a_mode),
    1.33                         FILE_ATTRIBUTE_NORMAL, NULL);
    1.34 -        SDL_stack_free(filenameW);
    1.35 +        SDL_free(tstr);
    1.36      }
    1.37  #else
    1.38      /* Do not open a dialog box if failure */
    1.39      old_error_mode =
    1.40          SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
    1.41  
    1.42 -    h = CreateFile(filename, (w_right | r_right),
    1.43 -                   (w_right) ? 0 : FILE_SHARE_READ, NULL,
    1.44 -                   (must_exist | truncate | a_mode), FILE_ATTRIBUTE_NORMAL,
    1.45 -                   NULL);
    1.46 +    {
    1.47 +        LPTSTR tstr = WIN_UTF8ToString(filename);
    1.48 +        h = CreateFile(tstr, (w_right | r_right),
    1.49 +                       (w_right) ? 0 : FILE_SHARE_READ, NULL,
    1.50 +                       (must_exist | truncate | a_mode),
    1.51 +                       FILE_ATTRIBUTE_NORMAL, NULL);
    1.52 +        SDL_free(tstr);
    1.53 +    }
    1.54  
    1.55 -    /* restore old behaviour */
    1.56 +    /* restore old behavior */
    1.57      SetErrorMode(old_error_mode);
    1.58  #endif /* _WIN32_WCE */
    1.59