Mercurial > repos > blastem
diff util.c @ 2215:a8af8d898a7c
Fix windows build for real
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 30 Aug 2022 00:13:55 -0700 |
parents | bdd83b47d78a |
children | 1a3991ada927 |
line wrap: on
line diff
--- a/util.c Mon Aug 29 23:01:46 2022 -0700 +++ b/util.c Tue Aug 30 00:13:55 2022 -0700 @@ -28,10 +28,13 @@ #define fatal_printf(msg, args) vfprintf(stderr, msg, args) #endif -#include "blastem.h" //for headless global -#include "render.h" //for render_errorbox #include "util.h" +void render_errorbox(char *title, char *message); +void render_warnbox(char *title, char *message); +void render_infobox(char *title, char *message); +extern int headless; + char * alloc_concat(char const * first, char const * second) { int flen = strlen(first); @@ -349,7 +352,7 @@ char *barename = malloc(lastdot-lastslash+1); memcpy(barename, lastslash, lastdot-lastslash); barename[lastdot-lastslash] = 0; - + return barename; } @@ -407,7 +410,7 @@ char *dir = malloc(lastslash-path+1); memcpy(dir, path, lastslash-path); dir[lastslash-path] = 0; - + return dir; } @@ -630,18 +633,18 @@ } return NULL; } - + size_t storage = 64; ret = malloc(sizeof(dir_entry) * storage); size_t pos = 0; - + if (path[1] == ':' && (!path[2] || (path[2] == PATH_SEP[0] && !path[3]))) { //we are in the root of a drive, add a virtual .. entry //for navigating to the virtual root directory ret[pos].name = strdup(".."); ret[pos++].is_dir = 1; } - + do { if (pos == storage) { storage = storage * 2; @@ -650,7 +653,7 @@ ret[pos].name = strdup(file.cFileName); ret[pos++].is_dir = (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; } while (FindNextFile(dir, &file)); - + FindClose(dir); if (numret) { *numret = pos; @@ -1074,7 +1077,7 @@ static char* confdir; if (!confdir) { char const *base = get_userdata_dir(); - if (base) { + if (base) { confdir = alloc_concat(base, PATH_SEP "blastem"); } }