Fixed bug #925
Changed "win32" to "windows" --HG-- rename : include/SDL_config_win32.h => include/SDL_config_windows.h rename : src/events/scancodes_win32.h => src/events/scancodes_windows.h rename : src/haptic/win32/SDL_syshaptic.c => src/haptic/windows/SDL_syshaptic.c rename : src/joystick/win32/SDL_dxjoystick.c => src/joystick/windows/SDL_dxjoystick.c rename : src/joystick/win32/SDL_dxjoystick_c.h => src/joystick/windows/SDL_dxjoystick_c.h rename : src/joystick/win32/SDL_mmjoystick.c => src/joystick/windows/SDL_mmjoystick.c rename : src/loadso/win32/SDL_sysloadso.c => src/loadso/windows/SDL_sysloadso.c rename : src/main/win32/SDL_win32_main.c => src/main/windows/SDL_windows_main.c rename : src/main/win32/version.rc => src/main/windows/version.rc rename : src/thread/win32/SDL_sysmutex.c => src/thread/windows/SDL_sysmutex.c rename : src/thread/win32/SDL_syssem.c => src/thread/windows/SDL_syssem.c rename : src/thread/win32/SDL_systhread.c => src/thread/windows/SDL_systhread.c rename : src/thread/win32/SDL_systhread_c.h => src/thread/windows/SDL_systhread_c.h rename : src/thread/win32/win_ce_semaphore.c => src/thread/windows/win_ce_semaphore.c rename : src/thread/win32/win_ce_semaphore.h => src/thread/windows/win_ce_semaphore.h rename : src/timer/win32/SDL_systimer.c => src/timer/windows/SDL_systimer.c rename : src/video/win32/SDL_ceddrawrender.c => src/video/windows/SDL_ceddrawrender.c rename : src/video/win32/SDL_ceddrawrender.h => src/video/windows/SDL_ceddrawrender.h rename : src/video/win32/SDL_d3drender.c => src/video/windows/SDL_d3drender.c rename : src/video/win32/SDL_d3drender.h => src/video/windows/SDL_d3drender.h rename : src/video/win32/SDL_gapirender.c => src/video/windows/SDL_gapirender.c rename : src/video/win32/SDL_gapirender.h => src/video/windows/SDL_gapirender.h rename : src/video/win32/SDL_gapirender_c.h => src/video/windows/SDL_gapirender_c.h rename : src/video/win32/SDL_gdirender.c => src/video/windows/SDL_gdirender.c rename : src/video/win32/SDL_gdirender.h => src/video/windows/SDL_gdirender.h rename : src/video/win32/SDL_msctf.h => src/video/windows/SDL_msctf.h rename : src/video/win32/SDL_vkeys.h => src/video/windows/SDL_vkeys.h rename : src/video/win32/SDL_win32clipboard.c => src/video/windows/SDL_windowsclipboard.c rename : src/video/win32/SDL_win32clipboard.h => src/video/windows/SDL_windowsclipboard.h rename : src/video/win32/SDL_win32events.c => src/video/windows/SDL_windowsevents.c rename : src/video/win32/SDL_win32events.h => src/video/windows/SDL_windowsevents.h rename : src/video/win32/SDL_win32gamma.c => src/video/windows/SDL_windowsgamma.c rename : src/video/win32/SDL_win32gamma.h => src/video/windows/SDL_windowsgamma.h rename : src/video/win32/SDL_win32keyboard.c => src/video/windows/SDL_windowskeyboard.c rename : src/video/win32/SDL_win32keyboard.h => src/video/windows/SDL_windowskeyboard.h rename : src/video/win32/SDL_win32modes.c => src/video/windows/SDL_windowsmodes.c rename : src/video/win32/SDL_win32modes.h => src/video/windows/SDL_windowsmodes.h rename : src/video/win32/SDL_win32mouse.c => src/video/windows/SDL_windowsmouse.c rename : src/video/win32/SDL_win32mouse.h => src/video/windows/SDL_windowsmouse.h rename : src/video/win32/SDL_win32opengl.c => src/video/windows/SDL_windowsopengl.c rename : src/video/win32/SDL_win32opengl.h => src/video/windows/SDL_windowsopengl.h rename : src/video/win32/SDL_win32shape.c => src/video/windows/SDL_windowsshape.c rename : src/video/win32/SDL_win32shape.h => src/video/windows/SDL_windowsshape.h rename : src/video/win32/SDL_win32video.c => src/video/windows/SDL_windowsvideo.c rename : src/video/win32/SDL_win32video.h => src/video/windows/SDL_windowsvideo.h rename : src/video/win32/SDL_win32window.c => src/video/windows/SDL_windowswindow.c rename : src/video/win32/SDL_win32window.h => src/video/windows/SDL_windowswindow.h rename : src/video/win32/wmmsg.h => src/video/windows/wmmsg.h
This commit is contained in:
parent
ee1f71dd63
commit
9d25ba272a
82 changed files with 382 additions and 375 deletions
|
@ -37,7 +37,7 @@
|
|||
#include <fat.h>
|
||||
#endif /* __NDS__ */
|
||||
|
||||
#ifdef __WIN32__
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
/* Functions to read/write Win32 API file pointers */
|
||||
/* Will not use it on WinCE because stdio is buffered, it means
|
||||
|
@ -54,7 +54,7 @@
|
|||
#define READAHEAD_BUFFER_SIZE 1024
|
||||
|
||||
static int SDLCALL
|
||||
win32_file_open(SDL_RWops * context, const char *filename, const char *mode)
|
||||
windows_file_open(SDL_RWops * context, const char *filename, const char *mode)
|
||||
{
|
||||
#ifndef _WIN32_WCE
|
||||
UINT old_error_mode;
|
||||
|
@ -67,10 +67,10 @@ win32_file_open(SDL_RWops * context, const char *filename, const char *mode)
|
|||
if (!context)
|
||||
return -1; /* failed (invalid call) */
|
||||
|
||||
context->hidden.win32io.h = INVALID_HANDLE_VALUE; /* mark this as unusable */
|
||||
context->hidden.win32io.buffer.data = NULL;
|
||||
context->hidden.win32io.buffer.size = 0;
|
||||
context->hidden.win32io.buffer.left = 0;
|
||||
context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* mark this as unusable */
|
||||
context->hidden.windowsio.buffer.data = NULL;
|
||||
context->hidden.windowsio.buffer.size = 0;
|
||||
context->hidden.windowsio.buffer.left = 0;
|
||||
|
||||
/* "r" = reading, file must exist */
|
||||
/* "w" = writing, truncate existing, file may not exist */
|
||||
|
@ -90,9 +90,9 @@ win32_file_open(SDL_RWops * context, const char *filename, const char *mode)
|
|||
if (!r_right && !w_right) /* inconsistent mode */
|
||||
return -1; /* failed (invalid call) */
|
||||
|
||||
context->hidden.win32io.buffer.data =
|
||||
context->hidden.windowsio.buffer.data =
|
||||
(char *) SDL_malloc(READAHEAD_BUFFER_SIZE);
|
||||
if (!context->hidden.win32io.buffer.data) {
|
||||
if (!context->hidden.windowsio.buffer.data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
|
@ -104,8 +104,8 @@ win32_file_open(SDL_RWops * context, const char *filename, const char *mode)
|
|||
if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, size) ==
|
||||
0) {
|
||||
SDL_stack_free(filenameW);
|
||||
SDL_free(context->hidden.win32io.buffer.data);
|
||||
context->hidden.win32io.buffer.data = NULL;
|
||||
SDL_free(context->hidden.windowsio.buffer.data);
|
||||
context->hidden.windowsio.buffer.data = NULL;
|
||||
SDL_SetError("Unable to convert filename to Unicode");
|
||||
return -1;
|
||||
}
|
||||
|
@ -130,51 +130,51 @@ win32_file_open(SDL_RWops * context, const char *filename, const char *mode)
|
|||
#endif /* _WIN32_WCE */
|
||||
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
SDL_free(context->hidden.win32io.buffer.data);
|
||||
context->hidden.win32io.buffer.data = NULL;
|
||||
SDL_free(context->hidden.windowsio.buffer.data);
|
||||
context->hidden.windowsio.buffer.data = NULL;
|
||||
SDL_SetError("Couldn't open %s", filename);
|
||||
return -2; /* failed (CreateFile) */
|
||||
}
|
||||
context->hidden.win32io.h = h;
|
||||
context->hidden.win32io.append = a_mode ? SDL_TRUE : SDL_FALSE;
|
||||
context->hidden.windowsio.h = h;
|
||||
context->hidden.windowsio.append = a_mode ? SDL_TRUE : SDL_FALSE;
|
||||
|
||||
return 0; /* ok */
|
||||
}
|
||||
|
||||
static long SDLCALL
|
||||
win32_file_seek(SDL_RWops * context, long offset, int whence)
|
||||
windows_file_seek(SDL_RWops * context, long offset, int whence)
|
||||
{
|
||||
DWORD win32whence;
|
||||
DWORD windowswhence;
|
||||
long file_pos;
|
||||
|
||||
if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE) {
|
||||
SDL_SetError("win32_file_seek: invalid context/file not opened");
|
||||
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
|
||||
SDL_SetError("windows_file_seek: invalid context/file not opened");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* FIXME: We may be able to satisfy the seek within buffered data */
|
||||
if (whence == RW_SEEK_CUR && context->hidden.win32io.buffer.left) {
|
||||
offset -= (long)context->hidden.win32io.buffer.left;
|
||||
if (whence == RW_SEEK_CUR && context->hidden.windowsio.buffer.left) {
|
||||
offset -= (long)context->hidden.windowsio.buffer.left;
|
||||
}
|
||||
context->hidden.win32io.buffer.left = 0;
|
||||
context->hidden.windowsio.buffer.left = 0;
|
||||
|
||||
switch (whence) {
|
||||
case RW_SEEK_SET:
|
||||
win32whence = FILE_BEGIN;
|
||||
windowswhence = FILE_BEGIN;
|
||||
break;
|
||||
case RW_SEEK_CUR:
|
||||
win32whence = FILE_CURRENT;
|
||||
windowswhence = FILE_CURRENT;
|
||||
break;
|
||||
case RW_SEEK_END:
|
||||
win32whence = FILE_END;
|
||||
windowswhence = FILE_END;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("win32_file_seek: Unknown value for 'whence'");
|
||||
SDL_SetError("windows_file_seek: Unknown value for 'whence'");
|
||||
return -1;
|
||||
}
|
||||
|
||||
file_pos =
|
||||
SetFilePointer(context->hidden.win32io.h, offset, NULL, win32whence);
|
||||
SetFilePointer(context->hidden.windowsio.h, offset, NULL, windowswhence);
|
||||
|
||||
if (file_pos != INVALID_SET_FILE_POINTER)
|
||||
return file_pos; /* success */
|
||||
|
@ -184,7 +184,7 @@ win32_file_seek(SDL_RWops * context, long offset, int whence)
|
|||
}
|
||||
|
||||
static size_t SDLCALL
|
||||
win32_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
||||
windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
||||
{
|
||||
size_t total_need;
|
||||
size_t total_read = 0;
|
||||
|
@ -193,18 +193,18 @@ win32_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
|||
|
||||
total_need = size * maxnum;
|
||||
|
||||
if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE
|
||||
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
|
||||
|| !total_need)
|
||||
return 0;
|
||||
|
||||
if (context->hidden.win32io.buffer.left > 0) {
|
||||
void *data = (char *) context->hidden.win32io.buffer.data +
|
||||
context->hidden.win32io.buffer.size -
|
||||
context->hidden.win32io.buffer.left;
|
||||
if (context->hidden.windowsio.buffer.left > 0) {
|
||||
void *data = (char *) context->hidden.windowsio.buffer.data +
|
||||
context->hidden.windowsio.buffer.size -
|
||||
context->hidden.windowsio.buffer.left;
|
||||
read_ahead =
|
||||
SDL_min(total_need, context->hidden.win32io.buffer.left);
|
||||
SDL_min(total_need, context->hidden.windowsio.buffer.left);
|
||||
SDL_memcpy(ptr, data, read_ahead);
|
||||
context->hidden.win32io.buffer.left -= read_ahead;
|
||||
context->hidden.windowsio.buffer.left -= read_ahead;
|
||||
|
||||
if (read_ahead == total_need) {
|
||||
return maxnum;
|
||||
|
@ -216,19 +216,19 @@ win32_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
|||
|
||||
if (total_need < READAHEAD_BUFFER_SIZE) {
|
||||
if (!ReadFile
|
||||
(context->hidden.win32io.h, context->hidden.win32io.buffer.data,
|
||||
(context->hidden.windowsio.h, context->hidden.windowsio.buffer.data,
|
||||
READAHEAD_BUFFER_SIZE, &byte_read, NULL)) {
|
||||
SDL_Error(SDL_EFREAD);
|
||||
return 0;
|
||||
}
|
||||
read_ahead = SDL_min(total_need, (int) byte_read);
|
||||
SDL_memcpy(ptr, context->hidden.win32io.buffer.data, read_ahead);
|
||||
context->hidden.win32io.buffer.size = byte_read;
|
||||
context->hidden.win32io.buffer.left = byte_read - read_ahead;
|
||||
SDL_memcpy(ptr, context->hidden.windowsio.buffer.data, read_ahead);
|
||||
context->hidden.windowsio.buffer.size = byte_read;
|
||||
context->hidden.windowsio.buffer.left = byte_read - read_ahead;
|
||||
total_read += read_ahead;
|
||||
} else {
|
||||
if (!ReadFile
|
||||
(context->hidden.win32io.h, ptr, (DWORD)total_need, &byte_read, NULL)) {
|
||||
(context->hidden.windowsio.h, ptr, (DWORD)total_need, &byte_read, NULL)) {
|
||||
SDL_Error(SDL_EFREAD);
|
||||
return 0;
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ win32_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
|||
}
|
||||
|
||||
static size_t SDLCALL
|
||||
win32_file_write(SDL_RWops * context, const void *ptr, size_t size,
|
||||
windows_file_write(SDL_RWops * context, const void *ptr, size_t size,
|
||||
size_t num)
|
||||
{
|
||||
|
||||
|
@ -248,20 +248,20 @@ win32_file_write(SDL_RWops * context, const void *ptr, size_t size,
|
|||
|
||||
total_bytes = size * num;
|
||||
|
||||
if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE
|
||||
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
|
||||
|| total_bytes <= 0 || !size)
|
||||
return 0;
|
||||
|
||||
if (context->hidden.win32io.buffer.left) {
|
||||
SetFilePointer(context->hidden.win32io.h,
|
||||
-(LONG)context->hidden.win32io.buffer.left, NULL,
|
||||
if (context->hidden.windowsio.buffer.left) {
|
||||
SetFilePointer(context->hidden.windowsio.h,
|
||||
-(LONG)context->hidden.windowsio.buffer.left, NULL,
|
||||
FILE_CURRENT);
|
||||
context->hidden.win32io.buffer.left = 0;
|
||||
context->hidden.windowsio.buffer.left = 0;
|
||||
}
|
||||
|
||||
/* if in append mode, we must go to the EOF before write */
|
||||
if (context->hidden.win32io.append) {
|
||||
if (SetFilePointer(context->hidden.win32io.h, 0L, NULL, FILE_END) ==
|
||||
if (context->hidden.windowsio.append) {
|
||||
if (SetFilePointer(context->hidden.windowsio.h, 0L, NULL, FILE_END) ==
|
||||
INVALID_SET_FILE_POINTER) {
|
||||
SDL_Error(SDL_EFWRITE);
|
||||
return 0;
|
||||
|
@ -269,7 +269,7 @@ win32_file_write(SDL_RWops * context, const void *ptr, size_t size,
|
|||
}
|
||||
|
||||
if (!WriteFile
|
||||
(context->hidden.win32io.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) {
|
||||
(context->hidden.windowsio.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) {
|
||||
SDL_Error(SDL_EFWRITE);
|
||||
return 0;
|
||||
}
|
||||
|
@ -279,23 +279,23 @@ win32_file_write(SDL_RWops * context, const void *ptr, size_t size,
|
|||
}
|
||||
|
||||
static int SDLCALL
|
||||
win32_file_close(SDL_RWops * context)
|
||||
windows_file_close(SDL_RWops * context)
|
||||
{
|
||||
|
||||
if (context) {
|
||||
if (context->hidden.win32io.h != INVALID_HANDLE_VALUE) {
|
||||
CloseHandle(context->hidden.win32io.h);
|
||||
context->hidden.win32io.h = INVALID_HANDLE_VALUE; /* to be sure */
|
||||
if (context->hidden.windowsio.h != INVALID_HANDLE_VALUE) {
|
||||
CloseHandle(context->hidden.windowsio.h);
|
||||
context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* to be sure */
|
||||
}
|
||||
if (context->hidden.win32io.buffer.data) {
|
||||
SDL_free(context->hidden.win32io.buffer.data);
|
||||
context->hidden.win32io.buffer.data = NULL;
|
||||
if (context->hidden.windowsio.buffer.data) {
|
||||
SDL_free(context->hidden.windowsio.buffer.data);
|
||||
context->hidden.windowsio.buffer.data = NULL;
|
||||
}
|
||||
SDL_FreeRW(context);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif /* __WIN32__ */
|
||||
#endif /* __WINDOWS__ */
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
|
||||
|
@ -449,18 +449,18 @@ SDL_RWFromFile(const char *file, const char *mode)
|
|||
SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
|
||||
return NULL;
|
||||
}
|
||||
#if defined(__WIN32__)
|
||||
#if defined(__WINDOWS__)
|
||||
rwops = SDL_AllocRW();
|
||||
if (!rwops)
|
||||
return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
|
||||
if (win32_file_open(rwops, file, mode) < 0) {
|
||||
if (windows_file_open(rwops, file, mode) < 0) {
|
||||
SDL_FreeRW(rwops);
|
||||
return NULL;
|
||||
}
|
||||
rwops->seek = win32_file_seek;
|
||||
rwops->read = win32_file_read;
|
||||
rwops->write = win32_file_write;
|
||||
rwops->close = win32_file_close;
|
||||
rwops->seek = windows_file_seek;
|
||||
rwops->read = windows_file_read;
|
||||
rwops->write = windows_file_write;
|
||||
rwops->close = windows_file_close;
|
||||
|
||||
#elif HAVE_STDIO_H
|
||||
#ifdef __APPLE__
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue