diff --git a/Makefile b/Makefile index 5bb7b00..7b73dbc 100755 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ loadso_OBJS = src/loadso/dummy/SDL_sysloadso.o power_OBJS = src/power/SDL_power.o -filesystem_OBJS = src/filesystem/dummy/SDL_sysfilesystem.o +filesystem_OBJS = src/filesystem/kolibri/SDL_sysfilesystem.o locale_OBJS = src/locale/SDL_locale.o src/locale/dummy/SDL_syslocale.o diff --git a/include/SDL_config_kolibri.h b/include/SDL_config_kolibri.h index 11a4758..d1a7b48 100644 --- a/include/SDL_config_kolibri.h +++ b/include/SDL_config_kolibri.h @@ -116,7 +116,7 @@ /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ #define SDL_LOADSO_DISABLED 1 -/* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */ -#define SDL_FILESYSTEM_DUMMY 1 +/* Enable the Kolibri filesystem driver (src/filesystem/kolibri/\*.c) */ +#define SDL_FILESYSTEM_KOLIBRI 1 #endif /* SDL_config_kolibri_h_ */ diff --git a/src/filesystem/kolibri/SDL_sysfilesystem.c b/src/filesystem/kolibri/SDL_sysfilesystem.c new file mode 100644 index 0000000..331cf78 --- /dev/null +++ b/src/filesystem/kolibri/SDL_sysfilesystem.c @@ -0,0 +1,55 @@ + +#include "../../SDL_internal.h" + +#ifdef SDL_FILESYSTEM_KOLIBRI + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include + +#include "SDL_error.h" +#include "SDL_filesystem.h" + +char *SDL_GetBasePath(void) +{ + char *retval = NULL; + size_t len; + char cwd[FILENAME_MAX]; + + _ksys_getcwd(cwd, sizeof(cwd)); + len = SDL_strlen(cwd) + 2; + retval = (char *)SDL_malloc(len); + SDL_snprintf(retval, len, "%s/", cwd); + + return retval; +} + +char *SDL_GetPrefPath(const char *org, const char *app) +{ + char *retval = NULL; + size_t len; + char *base = SDL_GetBasePath(); + if (!app) { + SDL_InvalidParamError("app"); + return NULL; + } + if (!org) { + org = ""; + } + + 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); + + _ksys_mkdir(retval); + return retval; +} + +#endif