Update for SDL3 coding style (#6717)

I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594

(cherry picked from commit 5750bcb174)
This commit is contained in:
Sam Lantinga
2022-11-30 12:51:59 -08:00
parent 5c4bc807f7
commit b8d85c6939
764 changed files with 50598 additions and 54407 deletions

View File

@@ -45,7 +45,7 @@ SDL_GetPrefPath(const char *org, const char *app)
{
const char *path = SDL_AndroidGetInternalStoragePath();
if (path) {
size_t pathlen = SDL_strlen(path)+2;
size_t pathlen = SDL_strlen(path) + 2;
char *fullpath = (char *)SDL_malloc(pathlen);
if (fullpath == NULL) {
SDL_OutOfMemory();

View File

@@ -35,105 +35,106 @@
char *
SDL_GetBasePath(void)
{ @autoreleasepool
{
NSBundle *bundle = [NSBundle mainBundle];
const char* baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String];
const char *base = NULL;
char *retval = NULL;
@autoreleasepool {
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";
}
if (SDL_strcasecmp(baseType, "bundle")==0) {
base = [[bundle bundlePath] fileSystemRepresentation];
} else if (SDL_strcasecmp(baseType, "parent")==0) {
base = [[[bundle bundlePath] stringByDeletingLastPathComponent] fileSystemRepresentation];
} else {
/* 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);
if (retval == NULL) {
SDL_OutOfMemory();
if (baseType == NULL) {
baseType = "resource";
}
if (SDL_strcasecmp(baseType, "bundle") == 0) {
base = [[bundle bundlePath] fileSystemRepresentation];
} else if (SDL_strcasecmp(baseType, "parent") == 0) {
base = [[[bundle bundlePath] stringByDeletingLastPathComponent] fileSystemRepresentation];
} else {
SDL_snprintf(retval, len, "%s/", base);
/* this returns the exedir for non-bundled and the resourceDir for bundled apps */
base = [[bundle resourcePath] fileSystemRepresentation];
}
}
return retval;
}}
char *
SDL_GetPrefPath(const char *org, const char *app)
{ @autoreleasepool
{
char *retval = NULL;
NSArray *array;
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (!org) {
org = "";
}
#if !TARGET_OS_TV
array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
#else
/* tvOS does not have persistent local storage!
* The only place on-device where we can store data is
* a cache directory that the OS can empty at any time.
*
* It's therefore very likely that save data will be erased
* between sessions. If you want your app's save data to
* actually stick around, you'll need to use iCloud storage.
*/
{
static SDL_bool shown = SDL_FALSE;
if (!shown)
{
shown = SDL_TRUE;
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "tvOS does not have persistent local storage! Use iCloud storage if you want your data to persist between sessions.\n");
}
}
array = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
#endif /* !TARGET_OS_TV */
if ([array count] > 0) { /* we only want the first item in the list. */
NSString *str = [array objectAtIndex:0];
const char *base = [str fileSystemRepresentation];
if (base) {
const size_t len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4;
retval = (char *) SDL_malloc(len);
const size_t len = SDL_strlen(base) + 2;
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
SDL_OutOfMemory();
} else {
char *ptr;
if (*org) {
SDL_snprintf(retval, len, "%s/%s/%s/", base, org, app);
} else {
SDL_snprintf(retval, len, "%s/%s/", base, app);
}
for (ptr = retval+1; *ptr; ptr++) {
if (*ptr == '/') {
*ptr = '\0';
mkdir(retval, 0700);
*ptr = '/';
}
}
mkdir(retval, 0700);
SDL_snprintf(retval, len, "%s/", base);
}
}
}
return retval;
}}
return retval;
}
}
char *
SDL_GetPrefPath(const char *org, const char *app)
{
@autoreleasepool {
char *retval = NULL;
NSArray *array;
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (!org) {
org = "";
}
#if !TARGET_OS_TV
array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
#else
/* tvOS does not have persistent local storage!
* The only place on-device where we can store data is
* a cache directory that the OS can empty at any time.
*
* It's therefore very likely that save data will be erased
* between sessions. If you want your app's save data to
* actually stick around, you'll need to use iCloud storage.
*/
{
static SDL_bool shown = SDL_FALSE;
if (!shown) {
shown = SDL_TRUE;
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "tvOS does not have persistent local storage! Use iCloud storage if you want your data to persist between sessions.\n");
}
}
array = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
#endif /* !TARGET_OS_TV */
if ([array count] > 0) { /* we only want the first item in the list. */
NSString *str = [array objectAtIndex:0];
const char *base = [str fileSystemRepresentation];
if (base) {
const size_t len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4;
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
SDL_OutOfMemory();
} else {
char *ptr;
if (*org) {
SDL_snprintf(retval, len, "%s/%s/%s/", base, org, app);
} else {
SDL_snprintf(retval, len, "%s/%s/", base, app);
}
for (ptr = retval + 1; *ptr; ptr++) {
if (*ptr == '/') {
*ptr = '\0';
mkdir(retval, 0700);
*ptr = '/';
}
}
mkdir(retval, 0700);
}
}
}
return retval;
}
}
#endif /* SDL_FILESYSTEM_COCOA */

View File

@@ -56,7 +56,7 @@ SDL_GetPrefPath(const char *org, const char *app)
}
len = SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
retval = (char *) SDL_malloc(len);
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
SDL_OutOfMemory();
return NULL;
@@ -68,7 +68,7 @@ SDL_GetPrefPath(const char *org, const char *app)
SDL_snprintf(retval, len, "%s%s/", append, app);
}
for (ptr = retval+1; *ptr; ptr++) {
for (ptr = retval + 1; *ptr; ptr++) {
if (*ptr == '/') {
*ptr = '\0';
if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
@@ -79,7 +79,7 @@ SDL_GetPrefPath(const char *org, const char *app)
}
if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
error:
error:
SDL_SetError("Couldn't create directory '%s': '%s'", retval, strerror(errno));
SDL_free(retval);
return NULL;

View File

@@ -34,76 +34,77 @@
char *
SDL_GetBasePath(void)
{
char *retval;
size_t len;
char cwd[FILENAME_MAX];
char *retval;
size_t len;
char cwd[FILENAME_MAX];
getcwd(cwd, sizeof(cwd));
len = SDL_strlen(cwd) + 1;
retval = (char *) SDL_malloc(len);
if (retval) {
SDL_memcpy(retval, cwd, len);
}
getcwd(cwd, sizeof(cwd));
len = SDL_strlen(cwd) + 1;
retval = (char *)SDL_malloc(len);
if (retval) {
SDL_memcpy(retval, cwd, len);
}
return retval;
return retval;
}
/* Do a recursive mkdir of parents folders */
static void recursive_mkdir(const char *dir) {
char tmp[FILENAME_MAX];
char *base = SDL_GetBasePath();
char *p = NULL;
size_t len;
static void recursive_mkdir(const char *dir)
{
char tmp[FILENAME_MAX];
char *base = SDL_GetBasePath();
char *p = NULL;
size_t len;
snprintf(tmp, sizeof(tmp),"%s",dir);
len = strlen(tmp);
if (tmp[len - 1] == '/') {
tmp[len - 1] = 0;
}
for (p = tmp + 1; *p; p++) {
if (*p == '/') {
*p = 0;
// Just creating subfolders from current path
if (strstr(tmp, base) != NULL) {
mkdir(tmp, S_IRWXU);
}
*p = '/';
snprintf(tmp, sizeof(tmp), "%s", dir);
len = strlen(tmp);
if (tmp[len - 1] == '/') {
tmp[len - 1] = 0;
}
}
free(base);
mkdir(tmp, S_IRWXU);
for (p = tmp + 1; *p; p++) {
if (*p == '/') {
*p = 0;
// Just creating subfolders from current path
if (strstr(tmp, base) != NULL) {
mkdir(tmp, S_IRWXU);
}
*p = '/';
}
}
free(base);
mkdir(tmp, S_IRWXU);
}
char *
SDL_GetPrefPath(const char *org, const char *app)
{
char *retval = NULL;
size_t len;
char *base = SDL_GetBasePath();
if (app == NULL) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
org = "";
}
char *retval = NULL;
size_t len;
char *base = SDL_GetBasePath();
if (app == NULL) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
org = "";
}
len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4;
retval = (char *) SDL_malloc(len);
len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4;
retval = (char *)SDL_malloc(len);
if (*org) {
SDL_snprintf(retval, len, "%s%s/%s/", base, org, app);
} else {
SDL_snprintf(retval, len, "%s%s/", base, app);
}
free(base);
if (*org) {
SDL_snprintf(retval, len, "%s%s/%s/", base, org, app);
} else {
SDL_snprintf(retval, len, "%s%s/", base, app);
}
free(base);
recursive_mkdir(retval);
return retval;
recursive_mkdir(retval);
return retval;
}
#endif /* SDL_FILESYSTEM_PS2 */

View File

@@ -40,7 +40,7 @@ SDL_GetBasePath(void)
getcwd(cwd, sizeof(cwd));
len = SDL_strlen(cwd) + 2;
retval = (char *) SDL_malloc(len);
retval = (char *)SDL_malloc(len);
SDL_snprintf(retval, len, "%s/", cwd);
return retval;
@@ -61,7 +61,7 @@ SDL_GetPrefPath(const char *org, const char *app)
}
len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4;
retval = (char *) SDL_malloc(len);
retval = (char *)SDL_malloc(len);
if (*org) {
SDL_snprintf(retval, len, "%s%s/%s/", base, org, app);

View File

@@ -34,8 +34,7 @@
#include "SDL_filesystem.h"
/* Wrapper around __unixify_std that uses SDL's memory allocators */
static char *
SDL_unixify_std(const char *ro_path, char *buffer, size_t buf_len, int filetype)
static char *SDL_unixify_std(const char *ro_path, char *buffer, size_t buf_len, int filetype)
{
const char *const in_buf = buffer; /* = NULL if we allocate the buffer. */
@@ -73,8 +72,7 @@ SDL_unixify_std(const char *ro_path, char *buffer, size_t buf_len, int filetype)
return buffer;
}
static char *
canonicalisePath(const char *path, const char *pathVar)
static char *canonicalisePath(const char *path, const char *pathVar)
{
_kernel_oserror *error;
_kernel_swi_regs regs;
@@ -109,8 +107,7 @@ canonicalisePath(const char *path, const char *pathVar)
return buf;
}
static _kernel_oserror *
createDirectoryRecursive(char *path)
static _kernel_oserror *createDirectoryRecursive(char *path)
{
char *ptr = NULL;
_kernel_oserror *error;
@@ -119,7 +116,7 @@ createDirectoryRecursive(char *path)
regs.r[1] = (int)path;
regs.r[2] = 0;
for (ptr = path+1; *ptr; ptr++) {
for (ptr = path + 1; *ptr; ptr++) {
if (*ptr == '.') {
*ptr = '\0';
error = _kernel_swi(OS_File, &regs, &regs);
@@ -181,7 +178,7 @@ SDL_GetPrefPath(const char *org, const char *app)
}
len = SDL_strlen(canon) + SDL_strlen(org) + SDL_strlen(app) + 4;
dir = (char *) SDL_malloc(len);
dir = (char *)SDL_malloc(len);
if (dir == NULL) {
SDL_OutOfMemory();
SDL_free(canon);

View File

@@ -53,7 +53,7 @@ readSymLink(const char *path)
ssize_t rc = -1;
while (1) {
char *ptr = (char *) SDL_realloc(retval, (size_t) len);
char *ptr = (char *)SDL_realloc(retval, (size_t)len);
if (ptr == NULL) {
SDL_OutOfMemory();
break;
@@ -63,13 +63,13 @@ readSymLink(const char *path)
rc = readlink(path, retval, len);
if (rc == -1) {
break; /* not a symlink, i/o error, etc. */
break; /* not a symlink, i/o error, etc. */
} else if (rc < len) {
retval[rc] = '\0'; /* readlink doesn't null-terminate. */
return retval; /* we're good to go. */
retval[rc] = '\0'; /* readlink doesn't null-terminate. */
return retval; /* we're good to go. */
}
len *= 2; /* grow buffer, try again. */
len *= 2; /* grow buffer, try again. */
}
SDL_free(retval);
@@ -101,10 +101,10 @@ static char *search_path_for_binary(const char *bin)
SDL_assert(bin != NULL);
alloc_size = SDL_strlen(bin) + SDL_strlen(envr) + 2;
exe = (char *) SDL_malloc(alloc_size);
exe = (char *)SDL_malloc(alloc_size);
do {
ptr = SDL_strchr(start, ':'); /* find next $PATH separator. */
ptr = SDL_strchr(start, ':'); /* find next $PATH separator. */
if (ptr != start) {
if (ptr) {
*ptr = '\0';
@@ -118,19 +118,17 @@ static char *search_path_for_binary(const char *bin)
return exe;
}
}
start = ptr + 1; /* start points to beginning of next element. */
start = ptr + 1; /* start points to beginning of next element. */
} while (ptr != NULL);
SDL_free(envr);
SDL_free(exe);
SDL_SetError("Process not found in $PATH");
return NULL; /* doesn't exist in path. */
return NULL; /* doesn't exist in path. */
}
#endif
char *
SDL_GetBasePath(void)
{
@@ -138,7 +136,7 @@ SDL_GetBasePath(void)
#if defined(__FREEBSD__)
char fullpath[PATH_MAX];
size_t buflen = sizeof (fullpath);
size_t buflen = sizeof(fullpath);
const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
if (sysctl(mib, SDL_arraysize(mib), fullpath, &buflen, NULL, 0) != -1) {
retval = SDL_strdup(fullpath);
@@ -155,7 +153,7 @@ SDL_GetBasePath(void)
const int mib[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV };
if (sysctl(mib, 4, NULL, &len, NULL, 0) != -1) {
char *exe, *pwddst;
char *realpathbuf = (char *) SDL_malloc(PATH_MAX + 1);
char *realpathbuf = (char *)SDL_malloc(PATH_MAX + 1);
if (realpathbuf == NULL) {
SDL_OutOfMemory();
return NULL;
@@ -172,13 +170,13 @@ SDL_GetBasePath(void)
exe = cmdline[0];
pwddst = NULL;
if (SDL_strchr(exe, '/') == NULL) { /* not a relative or absolute path, check $PATH for it */
if (SDL_strchr(exe, '/') == NULL) { /* not a relative or absolute path, check $PATH for it */
exe = search_path_for_binary(cmdline[0]);
} else {
if (exe && *exe == '.') {
const char *pwd = SDL_getenv("PWD");
if (pwd && *pwd) {
SDL_asprintf(&pwddst, "%s/%s", pwd, exe);
SDL_asprintf(&pwddst, "%s/%s", pwd, exe);
}
}
}
@@ -222,14 +220,14 @@ SDL_GetBasePath(void)
#elif defined(__QNXNTO__)
retval = SDL_LoadFile("/proc/self/exefile", NULL);
#else
retval = readSymLink("/proc/self/exe"); /* linux. */
retval = readSymLink("/proc/self/exe"); /* linux. */
if (retval == NULL) {
/* older kernels don't have /proc/self ... try PID version... */
char path[64];
const int rc = SDL_snprintf(path, sizeof(path),
"/proc/%llu/exe",
(unsigned long long) getpid());
if ( (rc > 0) && (rc < sizeof(path)) ) {
"/proc/%llu/exe",
(unsigned long long)getpid());
if ((rc > 0) && (rc < sizeof(path))) {
retval = readSymLink(path);
}
}
@@ -255,8 +253,8 @@ SDL_GetBasePath(void)
if (retval != NULL) { /* chop off filename. */
char *ptr = SDL_strrchr(retval, '/');
if (ptr != NULL) {
*(ptr+1) = '\0';
} else { /* shouldn't happen, but just in case... */
*(ptr + 1) = '\0';
} else { /* shouldn't happen, but just in case... */
SDL_free(retval);
retval = NULL;
}
@@ -264,7 +262,7 @@ SDL_GetBasePath(void)
if (retval != NULL) {
/* try to shrink buffer... */
char *ptr = (char *) SDL_realloc(retval, SDL_strlen(retval) + 1);
char *ptr = (char *)SDL_realloc(retval, SDL_strlen(retval) + 1);
if (ptr != NULL) {
retval = ptr; /* oh well if it failed. */
}
@@ -316,7 +314,7 @@ SDL_GetPrefPath(const char *org, const char *app)
}
len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
retval = (char *) SDL_malloc(len);
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
SDL_OutOfMemory();
return NULL;
@@ -328,7 +326,7 @@ SDL_GetPrefPath(const char *org, const char *app)
SDL_snprintf(retval, len, "%s%s%s/", envr, append, app);
}
for (ptr = retval+1; *ptr; ptr++) {
for (ptr = retval + 1; *ptr; ptr++) {
if (*ptr == '/') {
*ptr = '\0';
if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
@@ -338,7 +336,7 @@ SDL_GetPrefPath(const char *org, const char *app)
}
}
if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
error:
error:
SDL_SetError("Couldn't create directory '%s': '%s'", retval, strerror(errno));
SDL_free(retval);
return NULL;

View File

@@ -66,7 +66,7 @@ SDL_GetPrefPath(const char *org, const char *app)
len = SDL_strlen(envr);
len += SDL_strlen(org) + SDL_strlen(app) + 3;
retval = (char *) SDL_malloc(len);
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
SDL_OutOfMemory();
return NULL;
@@ -78,7 +78,7 @@ SDL_GetPrefPath(const char *org, const char *app)
SDL_snprintf(retval, len, "%s%s/", envr, app);
}
for (ptr = retval+1; *ptr; ptr++) {
for (ptr = retval + 1; *ptr; ptr++) {
if (*ptr == '/') {
*ptr = '\0';
sceIoMkdir(retval, 0777);

View File

@@ -42,14 +42,14 @@ SDL_GetBasePath(void)
int i;
while (SDL_TRUE) {
void *ptr = SDL_realloc(path, buflen * sizeof (WCHAR));
void *ptr = SDL_realloc(path, buflen * sizeof(WCHAR));
if (ptr == NULL) {
SDL_free(path);
SDL_OutOfMemory();
return NULL;
}
path = (WCHAR *) ptr;
path = (WCHAR *)ptr;
len = GetModuleFileNameW(NULL, path, buflen);
/* if it truncated, then len >= buflen - 1 */
@@ -68,14 +68,14 @@ SDL_GetBasePath(void)
return NULL;
}
for (i = len-1; i > 0; i--) {
for (i = len - 1; i > 0; i--) {
if (path[i] == '\\') {
break;
}
}
SDL_assert(i > 0); /* Should have been an absolute path. */
path[i+1] = '\0'; /* chop off filename. */
SDL_assert(i > 0); /* Should have been an absolute path. */
path[i + 1] = '\0'; /* chop off filename. */
retval = WIN_StringToUTF8W(path);
SDL_free(path);
@@ -96,8 +96,8 @@ SDL_GetPrefPath(const char *org, const char *app)
WCHAR path[MAX_PATH];
char *retval = NULL;
WCHAR* worg = NULL;
WCHAR* wapp = NULL;
WCHAR *worg = NULL;
WCHAR *wapp = NULL;
size_t new_wpath_len = 0;
BOOL api_result = FALSE;
@@ -190,5 +190,4 @@ SDL_GetPrefPath(const char *org, const char *app)
}
#endif /* SDL_FILESYSTEM_XBOX */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -21,7 +21,7 @@
#include "../../SDL_internal.h"
/* TODO, WinRT: remove the need to compile this with C++/CX (/ZW) extensions, and if possible, without C++ at all
*/
*/
#ifdef __WINRT__
@@ -44,55 +44,55 @@ extern "C" const wchar_t *
SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType)
{
switch (pathType) {
case SDL_WINRT_PATH_INSTALLED_LOCATION:
{
static wstring path;
if (path.empty()) {
case SDL_WINRT_PATH_INSTALLED_LOCATION:
{
static wstring path;
if (path.empty()) {
#if defined(NTDDI_WIN10_19H1) && (NTDDI_VERSION >= NTDDI_WIN10_19H1) && (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) /* Only PC supports mods */
/* Windows 1903 supports mods, via the EffectiveLocation API */
if (Windows::Foundation::Metadata::ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8, 0)) {
path = Windows::ApplicationModel::Package::Current->EffectiveLocation->Path->Data();
} else {
path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
}
#else
/* Windows 1903 supports mods, via the EffectiveLocation API */
if (Windows::Foundation::Metadata::ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8, 0)) {
path = Windows::ApplicationModel::Package::Current->EffectiveLocation->Path->Data();
} else {
path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
}
#else
path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
#endif
}
return path.c_str();
}
return path.c_str();
}
case SDL_WINRT_PATH_LOCAL_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->LocalFolder->Path->Data();
}
return path.c_str();
case SDL_WINRT_PATH_LOCAL_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->LocalFolder->Path->Data();
}
return path.c_str();
}
#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION > NTDDI_WIN8)
case SDL_WINRT_PATH_ROAMING_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->RoamingFolder->Path->Data();
}
return path.c_str();
case SDL_WINRT_PATH_ROAMING_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->RoamingFolder->Path->Data();
}
return path.c_str();
}
case SDL_WINRT_PATH_TEMP_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->TemporaryFolder->Path->Data();
}
return path.c_str();
case SDL_WINRT_PATH_TEMP_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->TemporaryFolder->Path->Data();
}
return path.c_str();
}
#endif
default:
break;
default:
break;
}
SDL_Unsupported();
@@ -110,12 +110,12 @@ SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
return searchResult->second.c_str();
}
const wchar_t * ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType);
const wchar_t *ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType);
if (ucs2Path == NULL) {
return NULL;
}
char * utf8Path = WIN_StringToUTF8(ucs2Path);
char *utf8Path = WIN_StringToUTF8(ucs2Path);
utf8Paths[pathType] = utf8Path;
SDL_free(utf8Path);
return utf8Paths[pathType].c_str();
@@ -124,9 +124,9 @@ SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
extern "C" char *
SDL_GetBasePath(void)
{
const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_INSTALLED_LOCATION);
const char *srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_INSTALLED_LOCATION);
size_t destPathLen;
char * destPath = NULL;
char *destPath = NULL;
if (srcPath == NULL) {
SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError());
@@ -134,7 +134,7 @@ SDL_GetBasePath(void)
}
destPathLen = SDL_strlen(srcPath) + 2;
destPath = (char *) SDL_malloc(destPathLen);
destPath = (char *)SDL_malloc(destPathLen);
if (destPath == NULL) {
SDL_OutOfMemory();
return NULL;
@@ -153,11 +153,11 @@ SDL_GetPrefPath(const char *org, const char *app)
* without violating Microsoft's app-store requirements.
*/
const WCHAR * srcPath = NULL;
const WCHAR *srcPath = NULL;
WCHAR path[MAX_PATH];
char *retval = NULL;
WCHAR* worg = NULL;
WCHAR* wapp = NULL;
WCHAR *worg = NULL;
WCHAR *wapp = NULL;
size_t new_wpath_len = 0;
BOOL api_result = FALSE;