From 6d7ca05d4c359b96870da33bca86f31ebf4cde80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20V?= <42870867+AlienFuture@users.noreply.github.com> Date: Mon, 1 Mar 2021 16:48:13 +0100 Subject: [PATCH] Game creates automatically missing folder When the searched folder (e.g demo/screenshots) is missing the game will create the folder automatically instead of an error message --- src/qcommon/files.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/qcommon/files.cpp b/src/qcommon/files.cpp index 68b72b30b..7875dbe7a 100644 --- a/src/qcommon/files.cpp +++ b/src/qcommon/files.cpp @@ -44,6 +44,7 @@ #include "qcommon.h" #include "unzip.h" #include "vm.h" +#include #ifndef DEDICATED #include "client/cl_rest.h" @@ -450,6 +451,7 @@ bool FS_OpenBaseGamePath( const char *baseGamePath ) { const char *homePath = Sys_DefaultHomePath( ); const char *path; + struct stat st; if (!homePath || !homePath[0]) { @@ -457,10 +459,16 @@ bool FS_OpenBaseGamePath( const char *baseGamePath ) } path = FS_BuildOSPath( homePath, fs_basegame->string, baseGamePath); - - if( FS_OpenWithDefault( path ) ) + if(stat(path, &st) == 0 && !S_ISDIR(st.st_mode)) { + if( FS_OpenWithDefault( path )) return true; + } else { + FS_CreatePath(path); + } + if( FS_OpenWithDefault( path )) + return true; + Com_Printf( S_COLOR_RED "FS_BrowseHomepath: failed to open the homepath with the default file manager.\n" S_COLOR_WHITE ); return false; }