--- a/ui/common/properties.c Sun Nov 10 15:30:46 2024 +0100 +++ b/ui/common/properties.c Mon Nov 11 20:45:34 2024 +0100 @@ -60,6 +60,14 @@ return ui_configfile(NULL); } +#ifndef _WIN32 +#define UI_PATH_SEPARATOR '/' +#define UI_ENV_HOME "HOME" +#else +#define UI_PATH_SEPARATOR '\\' +#define UI_ENV_HOME "USERPROFILE" +#endif + char* ui_configfile(char *name) { const char *appname = ui_appname(); if(!appname) { @@ -70,7 +78,7 @@ cxBufferInit(&buf, NULL, 128, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); // add base dir - char *homeenv = getenv("HOME"); + char *homeenv = getenv(UI_ENV_HOME); if(homeenv == NULL) { cxBufferDestroy(&buf); return NULL; @@ -78,19 +86,22 @@ cxstring home = cx_str(homeenv); cxBufferWrite(home.ptr, 1, home.length, &buf); - if(home.ptr[home.length-1] != '/') { - cxBufferPut(&buf, '/'); + if(home.ptr[home.length-1] != UI_PATH_SEPARATOR) { + cxBufferPut(&buf, UI_PATH_SEPARATOR); } #ifdef UI_COCOA // on OS X the app dir is $HOME/Library/Application Support/$APPNAME/ - ucx_buffer_puts(buf, "Library/Application Support/"); + cxBufferPutString(&buf, "Library/Application Support/"); +#elif defined(_WIN32) + // on Windows the app dir is $USERPROFILE/AppData/Local/$APPNAME/ + cxBufferPutString(&buf, "AppData\\Local\\"); #else // app dir is $HOME/.$APPNAME/ cxBufferPut(&buf, '.'); #endif cxBufferPutString(&buf, appname); - cxBufferPut(&buf, '/'); + cxBufferPut(&buf, UI_PATH_SEPARATOR); // add file name if(name) {