comparison src/file/SDL_rwops.c @ 4040:8515468091e3 SDL-1.2

Set the error after freeing stuff, just in case one of those functions resets the error string.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 10 Jul 2007 19:03:44 +0000
parents 7fd9a811efc7
children a1b03ba2fcd0
comparison
equal deleted inserted replaced
4039:7fd9a811efc7 4040:8515468091e3
89 { 89 {
90 size_t size = SDL_strlen(filename)+1; 90 size_t size = SDL_strlen(filename)+1;
91 wchar_t *filenameW = SDL_stack_alloc(wchar_t, size); 91 wchar_t *filenameW = SDL_stack_alloc(wchar_t, size);
92 92
93 if ( MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, size) == 0 ) { 93 if ( MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, size) == 0 ) {
94 SDL_SetError("Unable to convert filename to Unicode");
95 SDL_stack_free(filenameW); 94 SDL_stack_free(filenameW);
96 SDL_free(context->hidden.win32io.buffer.data); 95 SDL_free(context->hidden.win32io.buffer.data);
97 context->hidden.win32io.buffer.data = NULL; 96 context->hidden.win32io.buffer.data = NULL;
97 SDL_SetError("Unable to convert filename to Unicode");
98 return -1; 98 return -1;
99 } 99 }
100 h = CreateFile(filenameW, (w_right|r_right), (w_right)? 0 : FILE_SHARE_READ, 100 h = CreateFile(filenameW, (w_right|r_right), (w_right)? 0 : FILE_SHARE_READ,
101 NULL, (must_exist|truncate|a_mode), FILE_ATTRIBUTE_NORMAL,NULL); 101 NULL, (must_exist|truncate|a_mode), FILE_ATTRIBUTE_NORMAL,NULL);
102 SDL_stack_free(filenameW); 102 SDL_stack_free(filenameW);
111 /* restore old behaviour */ 111 /* restore old behaviour */
112 SetErrorMode(old_error_mode); 112 SetErrorMode(old_error_mode);
113 #endif /* _WIN32_WCE */ 113 #endif /* _WIN32_WCE */
114 114
115 if (h==INVALID_HANDLE_VALUE) { 115 if (h==INVALID_HANDLE_VALUE) {
116 SDL_SetError("Couldn't open %s",filename);
117 SDL_free(context->hidden.win32io.buffer.data); 116 SDL_free(context->hidden.win32io.buffer.data);
118 context->hidden.win32io.buffer.data = NULL; 117 context->hidden.win32io.buffer.data = NULL;
118 SDL_SetError("Couldn't open %s",filename);
119 return -2; /* failed (CreateFile) */ 119 return -2; /* failed (CreateFile) */
120 } 120 }
121 context->hidden.win32io.h = h; 121 context->hidden.win32io.h = h;
122 context->hidden.win32io.append = a_mode; 122 context->hidden.win32io.append = a_mode;
123 123