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
This commit is contained in:
Sam Lantinga
2022-11-30 12:51:59 -08:00
committed by GitHub
parent 14b902faca
commit 5750bcb174
781 changed files with 51659 additions and 55763 deletions

View File

@@ -27,8 +27,6 @@
#include <unistd.h>
char *
SDL_GetBasePath(void)
{
@@ -42,7 +40,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

@@ -29,108 +29,108 @@
#include <sys/stat.h>
#include <sys/types.h>
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

@@ -25,7 +25,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* System dependent filesystem routines */
char *
SDL_GetBasePath(void)
{

View File

@@ -27,7 +27,6 @@
#include <errno.h>
#include <sys/stat.h>
#include <emscripten/emscripten.h>
char *
@@ -54,7 +53,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;
@@ -66,7 +65,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) {
@@ -77,7 +76,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

@@ -29,7 +29,6 @@
#include <dirent.h>
#include <errno.h>
SDL_FORCE_INLINE char *MakePrefPath(const char *app);
SDL_FORCE_INLINE int CreatePrefPathDir(const char *pref);

View File

@@ -28,80 +28,80 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* System dependent filesystem routines */
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

@@ -28,7 +28,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* System dependent filesystem routines */
char *
SDL_GetBasePath(void)
{
@@ -38,7 +37,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;
@@ -59,7 +58,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

@@ -29,10 +29,8 @@
#include <swis.h>
#include <unixlib/local.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. */
@@ -70,8 +68,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;
@@ -106,8 +103,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;
@@ -116,7 +112,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);
@@ -178,7 +174,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

@@ -38,16 +38,14 @@
#include <sys/sysctl.h>
#endif
static char *
readSymLink(const char *path)
static char *readSymLink(const char *path)
{
char *retval = NULL;
ssize_t len = 64;
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;
@@ -57,13 +55,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);
@@ -93,10 +91,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';
@@ -110,19 +108,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)
{
@@ -130,7 +126,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);
@@ -147,7 +143,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;
@@ -164,13 +160,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);
}
}
}
@@ -212,14 +208,14 @@ SDL_GetBasePath(void)
#elif defined(__SOLARIS__)
retval = readSymLink("/proc/self/path/a.out");
#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);
}
}
@@ -243,8 +239,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;
}
@@ -252,7 +248,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. */
}
@@ -304,7 +300,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;
@@ -316,7 +312,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) {
@@ -326,7 +322,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,7 +34,6 @@
#include <limits.h>
#include <fcntl.h>
char *
SDL_GetBasePath(void)
{
@@ -62,7 +61,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;
@@ -74,7 +73,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

@@ -28,7 +28,6 @@
#include "../../core/windows/SDL_windows.h"
#include <shlobj.h>
char *
SDL_GetBasePath(void)
{
@@ -39,14 +38,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 */
@@ -65,14 +64,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);
@@ -93,8 +92,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;
@@ -185,5 +184,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__
@@ -39,55 +39,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();
@@ -105,12 +105,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();
@@ -119,9 +119,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());
@@ -129,7 +129,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;
@@ -148,11 +148,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;