Skip to content

Commit 3db898c

Browse files
ccawley2011slouken
authored andcommitted
riscos: Implement SDL_GetPrefPath()
1 parent 723f5ce commit 3db898c

File tree

6 files changed

+115
-0
lines changed

6 files changed

+115
-0
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,6 +2114,13 @@ elseif(RISCOS)
21142114
set(SOURCE_FILES ${SOURCE_FILES} ${MISC_SOURCES})
21152115
set(HAVE_SDL_MISC TRUE)
21162116

2117+
if(SDL_FILESYSTEM)
2118+
set(SDL_FILESYSTEM_RISCOS 1)
2119+
file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/riscos/*.c)
2120+
set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
2121+
set(HAVE_SDL_FILESYSTEM TRUE)
2122+
endif()
2123+
21172124
if(SDL_TIMERS)
21182125
set(SDL_TIMER_UNIX 1)
21192126
file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)

configure

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25794,6 +25794,14 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
2579425794
SOURCES="$SOURCES $srcdir/src/misc/riscos/*.c"
2579525795
have_misc=yes
2579625796

25797+
# Set up files for the filesystem library
25798+
if test x$enable_filesystem = xyes; then
25799+
25800+
$as_echo "#define SDL_FILESYSTEM_RISCOS 1" >>confdefs.h
25801+
25802+
SOURCES="$SOURCES $srcdir/src/filesystem/riscos/*.c"
25803+
have_filesystem=yes
25804+
fi
2579725805
# Set up files for the timer library
2579825806
if test x$enable_timers = xyes; then
2579925807

configure.ac

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4277,6 +4277,12 @@ case "$host" in
42774277
SOURCES="$SOURCES $srcdir/src/misc/riscos/*.c"
42784278
have_misc=yes
42794279

4280+
# Set up files for the filesystem library
4281+
if test x$enable_filesystem = xyes; then
4282+
AC_DEFINE(SDL_FILESYSTEM_RISCOS, 1, [ ])
4283+
SOURCES="$SOURCES $srcdir/src/filesystem/riscos/*.c"
4284+
have_filesystem=yes
4285+
fi
42804286
# Set up files for the timer library
42814287
if test x$enable_timers = xyes; then
42824288
AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])

include/SDL_config.h.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@
469469
#cmakedefine SDL_FILESYSTEM_HAIKU @SDL_FILESYSTEM_HAIKU@
470470
#cmakedefine SDL_FILESYSTEM_COCOA @SDL_FILESYSTEM_COCOA@
471471
#cmakedefine SDL_FILESYSTEM_DUMMY @SDL_FILESYSTEM_DUMMY@
472+
#cmakedefine SDL_FILESYSTEM_RISCOS @SDL_FILESYSTEM_RISCOS@
472473
#cmakedefine SDL_FILESYSTEM_UNIX @SDL_FILESYSTEM_UNIX@
473474
#cmakedefine SDL_FILESYSTEM_WINDOWS @SDL_FILESYSTEM_WINDOWS@
474475
#cmakedefine SDL_FILESYSTEM_EMSCRIPTEN @SDL_FILESYSTEM_EMSCRIPTEN@

include/SDL_config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@
447447
#undef SDL_FILESYSTEM_ANDROID
448448
#undef SDL_FILESYSTEM_EMSCRIPTEN
449449
#undef SDL_FILESYSTEM_OS2
450+
#undef SDL_FILESYSTEM_RISCOS
450451

451452
/* Enable assembly routines */
452453
#undef SDL_ASSEMBLY_ROUTINES
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
Simple DirectMedia Layer
3+
Copyright (C) 1997-2019 Sam Lantinga <[email protected]>
4+
5+
This software is provided 'as-is', without any express or implied
6+
warranty. In no event will the authors be held liable for any damages
7+
arising from the use of this software.
8+
9+
Permission is granted to anyone to use this software for any purpose,
10+
including commercial applications, and to alter it and redistribute it
11+
freely, subject to the following restrictions:
12+
13+
1. The origin of this software must not be misrepresented; you must not
14+
claim that you wrote the original software. If you use this software
15+
in a product, an acknowledgment in the product documentation would be
16+
appreciated but is not required.
17+
2. Altered source versions must be plainly marked as such, and must not be
18+
misrepresented as being the original software.
19+
3. This notice may not be removed or altered from any source distribution.
20+
*/
21+
#include "../../SDL_internal.h"
22+
23+
#ifdef SDL_FILESYSTEM_RISCOS
24+
25+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
26+
/* System dependent filesystem routines */
27+
28+
#include <errno.h>
29+
#include <sys/stat.h>
30+
31+
#include "SDL_error.h"
32+
#include "SDL_stdinc.h"
33+
#include "SDL_filesystem.h"
34+
#include "SDL_rwops.h"
35+
36+
char *
37+
SDL_GetBasePath(void)
38+
{
39+
SDL_Unsupported();
40+
return NULL;
41+
}
42+
43+
char *
44+
SDL_GetPrefPath(const char *org, const char *app)
45+
{
46+
const char *prefix = "/<Choices$Write>/";
47+
char *retval = NULL;
48+
char *ptr = NULL;
49+
size_t len = 0;
50+
51+
if (!app) {
52+
SDL_InvalidParamError("app");
53+
return NULL;
54+
}
55+
if (!org) {
56+
org = "";
57+
}
58+
59+
len = SDL_strlen(prefix) + SDL_strlen(org) + SDL_strlen(app) + 3;
60+
retval = (char *) SDL_malloc(len);
61+
if (!retval) {
62+
SDL_OutOfMemory();
63+
return NULL;
64+
}
65+
66+
if (*org) {
67+
SDL_snprintf(retval, len, "%s%s/%s/", prefix, org, app);
68+
} else {
69+
SDL_snprintf(retval, len, "%s%s/", prefix, app);
70+
}
71+
72+
for (ptr = retval+1; *ptr; ptr++) {
73+
if (*ptr == '/') {
74+
*ptr = '\0';
75+
if (mkdir(retval, 0700) != 0 && errno != EEXIST)
76+
goto error;
77+
*ptr = '/';
78+
}
79+
}
80+
if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
81+
error:
82+
SDL_SetError("Couldn't create directory '%s': '%s'", retval, strerror(errno));
83+
SDL_free(retval);
84+
return NULL;
85+
}
86+
87+
return retval;
88+
}
89+
90+
#endif /* SDL_FILESYSTEM_RISCOS */
91+
92+
/* vi: set ts=4 sw=4 expandtab: */

0 commit comments

Comments
 (0)