From 691093ebf317a2c0f24d05c20ae1073f8372418c Mon Sep 17 00:00:00 2001 From: sorgelig Date: Tue, 10 Mar 2020 06:01:48 +0800 Subject: [PATCH] Create config path if doesn't exist. --- file_io.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/file_io.cpp b/file_io.cpp index 6a4287f..adaa94e 100644 --- a/file_io.cpp +++ b/file_io.cpp @@ -663,7 +663,17 @@ int FileLoadConfig(const char *name, void *pBuffer, int size) int FileSaveConfig(const char *name, void *pBuffer, int size) { - char path[256] = { CONFIG_DIR"/" }; + char path[256] = { CONFIG_DIR }; + const char *p; + while ((p = strchr(name, '/'))) + { + strcat(path, "/"); + strncat(path, name, p - name); + name = ++p; + FileCreatePath(path); + } + + strcat(path, "/"); strcat(path, name); return FileSave(path, pBuffer, size); }