mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
Updates SDL to version 2.0.4, which makes it compatible with VS2015.
This commit is contained in:
parent
7b52fed504
commit
b63ef177f4
924 changed files with 79241 additions and 39934 deletions
62
Engine/lib/sdl/src/filesystem/android/SDL_sysfilesystem.c
Normal file
62
Engine/lib/sdl/src/filesystem/android/SDL_sysfilesystem.c
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifdef SDL_FILESYSTEM_ANDROID
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* System dependent filesystem routines */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_filesystem.h"
|
||||
#include "SDL_system.h"
|
||||
|
||||
|
||||
char *
|
||||
SDL_GetBasePath(void)
|
||||
{
|
||||
/* The current working directory is / on Android */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
SDL_GetPrefPath(const char *org, const char *app)
|
||||
{
|
||||
const char *path = SDL_AndroidGetInternalStoragePath();
|
||||
if (path) {
|
||||
size_t pathlen = SDL_strlen(path)+2;
|
||||
char *fullpath = (char *)SDL_malloc(pathlen);
|
||||
if (!fullpath) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
SDL_snprintf(fullpath, pathlen, "%s/", path);
|
||||
return fullpath;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* SDL_FILESYSTEM_ANDROID */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -35,12 +35,13 @@
|
|||
|
||||
char *
|
||||
SDL_GetBasePath(void)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSBundle *bundle = [NSBundle mainBundle];
|
||||
const char* baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String];
|
||||
const char *base = NULL;
|
||||
char *retval = NULL;
|
||||
|
||||
if (baseType == NULL) {
|
||||
baseType = "resource";
|
||||
}
|
||||
|
|
@ -52,6 +53,7 @@ SDL_GetBasePath(void)
|
|||
/* this returns the exedir for non-bundled and the resourceDir for bundled apps */
|
||||
base = [[bundle resourcePath] fileSystemRepresentation];
|
||||
}
|
||||
|
||||
if (base) {
|
||||
const size_t len = SDL_strlen(base) + 2;
|
||||
retval = (char *) SDL_malloc(len);
|
||||
|
|
@ -62,17 +64,17 @@ SDL_GetBasePath(void)
|
|||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
return retval;
|
||||
}
|
||||
}}
|
||||
|
||||
char *
|
||||
SDL_GetPrefPath(const char *org, const char *app)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
||||
char *retval = NULL;
|
||||
|
||||
NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
||||
|
||||
if ([array count] > 0) { /* we only want the first item in the list. */
|
||||
NSString *str = [array objectAtIndex:0];
|
||||
const char *base = [str fileSystemRepresentation];
|
||||
|
|
@ -96,9 +98,8 @@ SDL_GetPrefPath(const char *org, const char *app)
|
|||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
return retval;
|
||||
}
|
||||
}}
|
||||
|
||||
#endif /* SDL_FILESYSTEM_COCOA */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
69
Engine/lib/sdl/src/filesystem/emscripten/SDL_sysfilesystem.c
Normal file
69
Engine/lib/sdl/src/filesystem/emscripten/SDL_sysfilesystem.c
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifdef SDL_FILESYSTEM_EMSCRIPTEN
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* System dependent filesystem routines */
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_filesystem.h"
|
||||
|
||||
#include <emscripten/emscripten.h>
|
||||
|
||||
char *
|
||||
SDL_GetBasePath(void)
|
||||
{
|
||||
char *retval = "/";
|
||||
return SDL_strdup(retval);
|
||||
}
|
||||
|
||||
char *
|
||||
SDL_GetPrefPath(const char *org, const char *app)
|
||||
{
|
||||
const char *append = "/libsdl/";
|
||||
char *retval;
|
||||
size_t len = 0;
|
||||
|
||||
len = SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
|
||||
retval = (char *) SDL_malloc(len);
|
||||
if (!retval) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_snprintf(retval, len, "%s%s/%s/", append, org, app);
|
||||
|
||||
if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
|
||||
SDL_SetError("Couldn't create directory '%s': '%s'", retval, strerror(errno));
|
||||
SDL_free(retval);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif /* SDL_FILESYSTEM_EMSCRIPTEN */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
42
Engine/lib/sdl/src/filesystem/nacl/SDL_sysfilesystem.c
Normal file
42
Engine/lib/sdl/src/filesystem/nacl/SDL_sysfilesystem.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_filesystem.h"
|
||||
|
||||
#ifdef SDL_FILESYSTEM_NACL
|
||||
|
||||
char *
|
||||
SDL_GetBasePath(void)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
SDL_GetPrefPath(const char *org, const char *app)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* SDL_FILESYSTEM_NACL */
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -197,7 +197,7 @@ SDL_GetPrefPath(const char *org, const char *app)
|
|||
}
|
||||
if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
|
||||
error:
|
||||
SDL_SetError("Couldn't create directory '%s': ", retval, strerror(errno));
|
||||
SDL_SetError("Couldn't create directory '%s': '%s'", retval, strerror(errno));
|
||||
SDL_free(retval);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -36,13 +36,51 @@
|
|||
char *
|
||||
SDL_GetBasePath(void)
|
||||
{
|
||||
TCHAR path[MAX_PATH];
|
||||
const DWORD len = GetModuleFileName(NULL, path, SDL_arraysize(path));
|
||||
size_t i;
|
||||
typedef DWORD (WINAPI *GetModuleFileNameExW_t)(HANDLE, HMODULE, LPWSTR, DWORD);
|
||||
GetModuleFileNameExW_t pGetModuleFileNameExW;
|
||||
DWORD buflen = 128;
|
||||
WCHAR *path = NULL;
|
||||
HANDLE psapi = LoadLibrary(L"psapi.dll");
|
||||
char *retval = NULL;
|
||||
DWORD len = 0;
|
||||
int i;
|
||||
|
||||
SDL_assert(len < SDL_arraysize(path));
|
||||
if (!psapi) {
|
||||
WIN_SetError("Couldn't load psapi.dll");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pGetModuleFileNameExW = (GetModuleFileNameExW_t)GetProcAddress(psapi, "GetModuleFileNameExW");
|
||||
if (!pGetModuleFileNameExW) {
|
||||
WIN_SetError("Couldn't find GetModuleFileNameExW");
|
||||
FreeLibrary(psapi);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (SDL_TRUE) {
|
||||
void *ptr = SDL_realloc(path, buflen * sizeof (WCHAR));
|
||||
if (!ptr) {
|
||||
SDL_free(path);
|
||||
FreeLibrary(psapi);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
path = (WCHAR *) ptr;
|
||||
|
||||
len = pGetModuleFileNameExW(GetCurrentProcess(), NULL, path, buflen);
|
||||
if (len != buflen) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* buffer too small? Try again. */
|
||||
buflen *= 2;
|
||||
}
|
||||
|
||||
FreeLibrary(psapi);
|
||||
|
||||
if (len == 0) {
|
||||
SDL_free(path);
|
||||
WIN_SetError("Couldn't locate our .exe");
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -55,7 +93,11 @@ SDL_GetBasePath(void)
|
|||
|
||||
SDL_assert(i > 0); /* Should have been an absolute path. */
|
||||
path[i+1] = '\0'; /* chop off filename. */
|
||||
return WIN_StringToUTF8(path);
|
||||
|
||||
retval = WIN_StringToUTF8(path);
|
||||
SDL_free(path);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
char *
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -20,8 +20,7 @@
|
|||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
/* TODO, WinRT: include copyright info in SDL_winrtpaths.cpp
|
||||
TODO, WinRT: remove the need to compile this with C++/CX (/ZW) extensions, and if possible, without C++ at all
|
||||
/* TODO, WinRT: remove the need to compile this with C++/CX (/ZW) extensions, and if possible, without C++ at all
|
||||
*/
|
||||
|
||||
#ifdef __WINRT__
|
||||
|
|
@ -29,6 +28,7 @@
|
|||
extern "C" {
|
||||
#include "SDL_filesystem.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_system.h"
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
|
@ -62,7 +62,7 @@ SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType)
|
|||
return path.c_str();
|
||||
}
|
||||
|
||||
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
|
||||
#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION > NTDDI_WIN8)
|
||||
case SDL_WINRT_PATH_ROAMING_FOLDER:
|
||||
{
|
||||
static wstring path;
|
||||
|
|
@ -144,31 +144,78 @@ SDL_GetPrefPath(const char *org, const char *app)
|
|||
* without violating Microsoft's app-store requirements.
|
||||
*/
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
/* A 'Roaming' folder is not available in Windows Phone 8, however a 'Local' folder is. */
|
||||
const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_LOCAL_FOLDER);
|
||||
#else
|
||||
/* A 'Roaming' folder is available on Windows 8 and 8.1. Use that. */
|
||||
const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_ROAMING_FOLDER);
|
||||
#endif
|
||||
const WCHAR * srcPath = NULL;
|
||||
WCHAR path[MAX_PATH];
|
||||
char *retval = NULL;
|
||||
WCHAR* worg = NULL;
|
||||
WCHAR* wapp = NULL;
|
||||
size_t new_wpath_len = 0;
|
||||
BOOL api_result = FALSE;
|
||||
|
||||
size_t destPathLen;
|
||||
char * destPath = NULL;
|
||||
|
||||
if (!srcPath) {
|
||||
SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError());
|
||||
srcPath = SDL_WinRTGetFSPathUNICODE(SDL_WINRT_PATH_LOCAL_FOLDER);
|
||||
if ( ! srcPath) {
|
||||
SDL_SetError("Unable to find a source path");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
destPathLen = SDL_strlen(srcPath) + SDL_strlen(org) + SDL_strlen(app) + 4;
|
||||
destPath = (char *) SDL_malloc(destPathLen);
|
||||
if (!destPath) {
|
||||
if (SDL_wcslen(srcPath) >= MAX_PATH) {
|
||||
SDL_SetError("Path too long.");
|
||||
return NULL;
|
||||
}
|
||||
SDL_wcslcpy(path, srcPath, SDL_arraysize(path));
|
||||
|
||||
worg = WIN_UTF8ToString(org);
|
||||
if (worg == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_snprintf(destPath, destPathLen, "%s\\%s\\%s\\", srcPath, org, app);
|
||||
return destPath;
|
||||
wapp = WIN_UTF8ToString(app);
|
||||
if (wapp == NULL) {
|
||||
SDL_free(worg);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_wpath_len = SDL_wcslen(worg) + SDL_wcslen(wapp) + SDL_wcslen(path) + 3;
|
||||
|
||||
if ((new_wpath_len + 1) > MAX_PATH) {
|
||||
SDL_free(worg);
|
||||
SDL_free(wapp);
|
||||
SDL_SetError("Path too long.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_wcslcat(path, L"\\", new_wpath_len + 1);
|
||||
SDL_wcslcat(path, worg, new_wpath_len + 1);
|
||||
SDL_free(worg);
|
||||
|
||||
api_result = CreateDirectoryW(path, NULL);
|
||||
if (api_result == FALSE) {
|
||||
if (GetLastError() != ERROR_ALREADY_EXISTS) {
|
||||
SDL_free(wapp);
|
||||
WIN_SetError("Couldn't create a prefpath.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_wcslcat(path, L"\\", new_wpath_len + 1);
|
||||
SDL_wcslcat(path, wapp, new_wpath_len + 1);
|
||||
SDL_free(wapp);
|
||||
|
||||
api_result = CreateDirectoryW(path, NULL);
|
||||
if (api_result == FALSE) {
|
||||
if (GetLastError() != ERROR_ALREADY_EXISTS) {
|
||||
WIN_SetError("Couldn't create a prefpath.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_wcslcat(path, L"\\", new_wpath_len + 1);
|
||||
|
||||
retval = WIN_StringToUTF8(path);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif /* __WINRT__ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue