diff --git a/consoleLib.c b/consoleLib.c index c41fc5e..e845c6c 100644 --- a/consoleLib.c +++ b/consoleLib.c @@ -138,6 +138,15 @@ mkdir(name, 0755); } + void getConfigPathPrefix(char* dest) { + strcpy(dest, getenv("HOME")); + strcat(dest, "/.jddev0"); + makeDirectory(dest); + strcat(dest, "/ConsoleSokoban"); + makeDirectory(dest); + strcat(dest, "/"); + } + void sleepMS(unsigned int time) { usleep(time * 1000); } @@ -374,6 +383,16 @@ _mkdir(name); } + void getConfigPathPrefix(char* dest) { + strcpy(dest, getenv("HOMEDRIVE")); + strcat(dest, getenv("HOMEPATH")); + strcat(dest, "/.jddev0"); + makeDirectory(dest); + strcat(dest, "/ConsoleSokoban"); + makeDirectory(dest); + strcat(dest, "/"); + } + void sleepMS(unsigned int time) { Sleep(time); } diff --git a/consoleLib.h b/consoleLib.h index 640256e..f545e3b 100644 --- a/consoleLib.h +++ b/consoleLib.h @@ -2,6 +2,8 @@ #define CONSOLE_LIB_H #define CONSOLE_LIB_VER "v0.0.1" + #define CONFIG_PATH_FOLDER "ConsoleSokoban" + //Keys //Arrow keys #define CL_KEY_LEFT 5000 @@ -41,6 +43,8 @@ void makeDirectory(const char* name); + void getConfigPathPrefix(char* dest); + void sleepMS(unsigned int time); void drawf(const char *restrict format, ...); diff --git a/main.c b/main.c index 04afed9..5741ccb 100644 --- a/main.c +++ b/main.c @@ -1076,12 +1076,7 @@ void readLevelData(void) { levelCount = 0; } - strcpy(pathMapSaveData, getenv("HOME")); - strcat(pathMapSaveData, "/.jddev0"); - makeDirectory(pathMapSaveData); - strcat(pathMapSaveData, "/ConsoleSokoban"); - makeDirectory(pathMapSaveData); - strcat(pathMapSaveData, "/"); + getConfigPathPrefix(pathMapSaveData); char mapData[65536]; int mapDataByteOffset = 0; @@ -1254,12 +1249,7 @@ void updateLevelPackStats(int levelPackIndex) { int levelCountTmp = 100; - strcpy(pathMapSaveData, getenv("HOME")); - strcat(pathMapSaveData, "/.jddev0"); - makeDirectory(pathMapSaveData); - strcat(pathMapSaveData, "/ConsoleSokoban"); - makeDirectory(pathMapSaveData); - strcat(pathMapSaveData, "/"); + getConfigPathPrefix(pathMapSaveData); if(strlen(build_in_map_prefix) <= strlen(pathMapData[currentMapIndex]) && memcmp(build_in_map_prefix, pathMapData[currentMapIndex], strlen(build_in_map_prefix)) == 0) {