early-access version 1667
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -44,6 +44,7 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
{
|
||||
const char *append = "/libsdl/";
|
||||
char *retval;
|
||||
char *ptr = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
if (!app) {
|
||||
@@ -67,7 +68,17 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
SDL_snprintf(retval, len, "%s%s/", append, app);
|
||||
}
|
||||
|
||||
for (ptr = retval+1; *ptr; ptr++) {
|
||||
if (*ptr == '/') {
|
||||
*ptr = '\0';
|
||||
if (mkdir(retval, 0700) != 0 && errno != EEXIST)
|
||||
goto error;
|
||||
*ptr = '/';
|
||||
}
|
||||
}
|
||||
|
||||
if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
|
||||
error:
|
||||
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-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -78,6 +78,60 @@ readSymLink(const char *path)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__OPENBSD__)
|
||||
static char *search_path_for_binary(const char *bin)
|
||||
{
|
||||
char *envr = getenv("PATH");
|
||||
size_t alloc_size;
|
||||
char *exe = NULL;
|
||||
char *start = envr;
|
||||
char *ptr;
|
||||
|
||||
if (!envr) {
|
||||
SDL_SetError("No $PATH set");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
envr = SDL_strdup(envr);
|
||||
if (!envr) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_assert(bin != NULL);
|
||||
|
||||
alloc_size = SDL_strlen(bin) + SDL_strlen(envr) + 2;
|
||||
exe = (char *) SDL_malloc(alloc_size);
|
||||
|
||||
do {
|
||||
ptr = SDL_strchr(start, ':'); /* find next $PATH separator. */
|
||||
if (ptr != start) {
|
||||
if (ptr) {
|
||||
*ptr = '\0';
|
||||
}
|
||||
|
||||
/* build full binary path... */
|
||||
SDL_snprintf(exe, alloc_size, "%s%s%s", start, (ptr && (ptr[-1] == '/')) ? "" : "/", bin);
|
||||
|
||||
if (access(exe, X_OK) == 0) { /* Exists as executable? We're done. */
|
||||
SDL_free(envr);
|
||||
return exe;
|
||||
}
|
||||
}
|
||||
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. */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
char *
|
||||
SDL_GetBasePath(void)
|
||||
{
|
||||
@@ -96,21 +150,47 @@ SDL_GetBasePath(void)
|
||||
}
|
||||
#endif
|
||||
#if defined(__OPENBSD__)
|
||||
char **retvalargs;
|
||||
/* Please note that this will fail if the process was launched with a relative path and the cwd has changed, or argv is altered. So don't do that. Or add a new sysctl to OpenBSD. */
|
||||
char **cmdline;
|
||||
size_t len;
|
||||
const int mib[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV };
|
||||
if (sysctl(mib, 4, NULL, &len, NULL, 0) != -1) {
|
||||
retvalargs = SDL_malloc(len);
|
||||
if (!retvalargs) {
|
||||
char *exe;
|
||||
char *realpathbuf = (char *) SDL_malloc(PATH_MAX + 1);
|
||||
if (!realpathbuf) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
sysctl(mib, 4, retvalargs, &len, NULL, 0);
|
||||
retval = SDL_malloc(PATH_MAX + 1);
|
||||
if (retval)
|
||||
realpath(retvalargs[0], retval);
|
||||
|
||||
SDL_free(retvalargs);
|
||||
cmdline = SDL_malloc(len);
|
||||
if (!cmdline) {
|
||||
SDL_free(realpathbuf);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sysctl(mib, 4, cmdline, &len, NULL, 0);
|
||||
|
||||
exe = cmdline[0];
|
||||
if (SDL_strchr(exe, '/') == NULL) { /* not a relative or absolute path, check $PATH for it */
|
||||
exe = search_path_for_binary(cmdline[0]);
|
||||
}
|
||||
|
||||
if (exe) {
|
||||
if (realpath(exe, realpathbuf) != NULL) {
|
||||
retval = realpathbuf;
|
||||
}
|
||||
|
||||
if (exe != cmdline[0]) {
|
||||
SDL_free(exe);
|
||||
}
|
||||
}
|
||||
|
||||
if (!retval) {
|
||||
SDL_free(realpathbuf);
|
||||
}
|
||||
|
||||
SDL_free(cmdline);
|
||||
}
|
||||
#endif
|
||||
#if defined(__SOLARIS__)
|
||||
|
95
externals/SDL/src/filesystem/vita/SDL_sysfilesystem.c
vendored
Executable file
95
externals/SDL/src/filesystem/vita/SDL_sysfilesystem.c
vendored
Executable file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_VITA
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* System dependent filesystem routines */
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <psp2/io/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <limits.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_filesystem.h"
|
||||
#include "SDL_rwops.h"
|
||||
|
||||
char *
|
||||
SDL_GetBasePath(void)
|
||||
{
|
||||
const char *basepath = "app0:/";
|
||||
char *retval = SDL_strdup(basepath);
|
||||
return retval;
|
||||
}
|
||||
|
||||
char *
|
||||
SDL_GetPrefPath(const char *org, const char *app)
|
||||
{
|
||||
const char *envr = "ux0:/data/";
|
||||
char *retval = NULL;
|
||||
char *ptr = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
if (!app) {
|
||||
SDL_InvalidParamError("app");
|
||||
return NULL;
|
||||
}
|
||||
if (!org) {
|
||||
org = "";
|
||||
}
|
||||
|
||||
len = SDL_strlen(envr);
|
||||
|
||||
len += SDL_strlen(org) + SDL_strlen(app) + 3;
|
||||
retval = (char *) SDL_malloc(len);
|
||||
if (!retval) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (*org) {
|
||||
SDL_snprintf(retval, len, "%s%s/%s/", envr, org, app);
|
||||
} else {
|
||||
SDL_snprintf(retval, len, "%s%s/", envr, app);
|
||||
}
|
||||
|
||||
for (ptr = retval+1; *ptr; ptr++) {
|
||||
if (*ptr == '/') {
|
||||
*ptr = '\0';
|
||||
sceIoMkdir(retval, 0777);
|
||||
*ptr = '/';
|
||||
}
|
||||
}
|
||||
sceIoMkdir(retval, 0777);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif /* SDL_FILESYSTEM_VITA */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -39,7 +39,7 @@ SDL_GetBasePath(void)
|
||||
GetModuleFileNameExW_t pGetModuleFileNameExW;
|
||||
DWORD buflen = 128;
|
||||
WCHAR *path = NULL;
|
||||
HANDLE psapi = LoadLibrary(L"psapi.dll");
|
||||
HANDLE psapi = LoadLibrary(TEXT("psapi.dll"));
|
||||
char *retval = NULL;
|
||||
DWORD len = 0;
|
||||
int i;
|
||||
@@ -93,7 +93,7 @@ SDL_GetBasePath(void)
|
||||
SDL_assert(i > 0); /* Should have been an absolute path. */
|
||||
path[i+1] = '\0'; /* chop off filename. */
|
||||
|
||||
retval = WIN_StringToUTF8(path);
|
||||
retval = WIN_StringToUTF8W(path);
|
||||
SDL_free(path);
|
||||
|
||||
return retval;
|
||||
@@ -130,20 +130,20 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
worg = WIN_UTF8ToString(org);
|
||||
worg = WIN_UTF8ToStringW(org);
|
||||
if (worg == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wapp = WIN_UTF8ToString(app);
|
||||
wapp = WIN_UTF8ToStringW(app);
|
||||
if (wapp == NULL) {
|
||||
SDL_free(worg);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_wpath_len = lstrlenW(worg) + lstrlenW(wapp) + lstrlenW(path) + 3;
|
||||
new_wpath_len = SDL_wcslen(worg) + SDL_wcslen(wapp) + SDL_wcslen(path) + 3;
|
||||
|
||||
if ((new_wpath_len + 1) > MAX_PATH) {
|
||||
SDL_free(worg);
|
||||
@@ -153,8 +153,8 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
}
|
||||
|
||||
if (*worg) {
|
||||
lstrcatW(path, L"\\");
|
||||
lstrcatW(path, worg);
|
||||
SDL_wcslcat(path, L"\\", SDL_arraysize(path));
|
||||
SDL_wcslcat(path, worg, SDL_arraysize(path));
|
||||
}
|
||||
SDL_free(worg);
|
||||
|
||||
@@ -167,8 +167,8 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
}
|
||||
}
|
||||
|
||||
lstrcatW(path, L"\\");
|
||||
lstrcatW(path, wapp);
|
||||
SDL_wcslcat(path, L"\\", SDL_arraysize(path));
|
||||
SDL_wcslcat(path, wapp, SDL_arraysize(path));
|
||||
SDL_free(wapp);
|
||||
|
||||
api_result = CreateDirectoryW(path, NULL);
|
||||
@@ -179,9 +179,9 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
}
|
||||
}
|
||||
|
||||
lstrcatW(path, L"\\");
|
||||
SDL_wcslcat(path, L"\\", SDL_arraysize(path));
|
||||
|
||||
retval = WIN_StringToUTF8(path);
|
||||
retval = WIN_StringToUTF8W(path);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
Reference in New Issue
Block a user