Mercurial > molko
changeset 36:798baf7f3ec0
core: implement sys_data* functions for Windows
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 13 Jan 2020 20:48:41 +0100 |
parents | bdb51709fd55 |
children | c33c8e9a89f6 |
files | src/main.c src/sys.c |
diffstat | 2 files changed, 19 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main.c Mon Jan 13 13:53:18 2020 +0100 +++ b/src/main.c Mon Jan 13 20:48:41 2020 +0100 @@ -16,11 +16,18 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <stdio.h> +#include <stdlib.h> + +#include "sys.h" + int main(int argc, char **argv) { (void)argc; (void)argv; + printf("[%s]\n", sys_datapath("foo.map")); + return 0; }
--- a/src/sys.c Mon Jan 13 13:53:18 2020 +0100 +++ b/src/sys.c Mon Jan 13 20:48:41 2020 +0100 @@ -23,9 +23,7 @@ #include <SDL_mixer.h> #include <SDL_ttf.h> -#if defined(_WIN32) -# error "TODO" -#else /* Assuming POSIX */ +#if !defined(_WIN32) /* Assuming POSIX */ # include <sys/types.h> # include <dirent.h> #endif @@ -33,7 +31,17 @@ #include "sys.h" #if defined(_WIN32) -# error "TODO" + +static void +determine(char path[], size_t pathlen) +{ + char *base = SDL_GetBasePath(); + + /* On Windows, the data hierarchy is the same as the project. */ + snprintf(path, pathlen, "%sassets", base); + SDL_free(base); +} + #else /* Assuming POSIX */ static bool