diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index 04428ab4..0d352d57 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -34,6 +34,8 @@ static int mkdir(char* path, int mode) #define MAX_PATH PATH_MAX #endif +static bool isInit = false; + static const char* pathSep = NULL; static char* basePath = NULL; static char saveDir[MAX_PATH] = {'\0'}; @@ -179,6 +181,8 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath) { vlog_info("gamecontrollerdb.txt not found!"); } + + isInit = true; return 1; } @@ -198,6 +202,7 @@ void FILESYSTEM_deinit(void) } SDL_free(basePath); basePath = NULL; + isInit = false; } char *FILESYSTEM_getUserSaveDirectory(void) @@ -910,6 +915,12 @@ fail: bool FILESYSTEM_saveTiXml2Document(const char *name, tinyxml2::XMLDocument& doc, bool sync /*= true*/) { + if (!isInit) + { + vlog_warn("Filesystem not initialized! Not writing just to be safe."); + return false; + } + /* XMLDocument.SaveFile doesn't account for Unicode paths, PHYSFS does */ tinyxml2::XMLPrinter printer; doc.Print(&printer);