diff --git a/src/common/io/io.h b/src/common/io/io.h index 257e9ce83..ec3375bd0 100644 --- a/src/common/io/io.h +++ b/src/common/io/io.h @@ -1,6 +1,7 @@ #pragma once #include "util/FFstrbuf.h" +#include "util/FFlist.h" #ifdef _WIN32 #include @@ -185,3 +186,18 @@ static inline bool wrapClosedir(HANDLE* pdir) } #endif #define FF_AUTO_CLOSE_DIR __attribute__((__cleanup__(wrapClosedir))) + +static inline bool ffSearchUserConfigFile(const FFlist* configDirs, const char* fileSubpath, FFstrbuf* result) +{ + // configDirs is a list of FFstrbufs include the trailing slash + FF_LIST_FOR_EACH(FFstrbuf, dir, *configDirs) + { + ffStrbufClear(result); + ffStrbufAppend(result, dir); + ffStrbufAppendS(result, fileSubpath); + if (ffPathExists(result->chars, FF_PATHTYPE_FILE)) + return true; + } + + return false; +}