We check file exists in CFile::Open() and CFile::Exists() for files, but not for dir in CDirectory::Exists() yet, this PR make CDirectory::Exists() also use directory cache to speed up the Exists operation.
Looks OK to me once rebased up.
Make CDirectory::Exists support use directory cache by default.
This causes a problem with changing the GUI language during runtime. CLocalizeStrings::LoadStr2Mem() calls CDirectory::Exists() with the path of the directory of the new language. g_directoryCache.FileExists() returnes false but bPathInCache returns true so the next if-condition fails and returns false.
EDIT: Seems like the problem is using g_directoryCache.FileExists() with a path to a directory as it expects a path to a file. It removes the file and checks the existance of its parent directory in the cache. But when you pass in a directory path, it removes the top-most directory and checks its parent path, which is cached. But the file cache only stores files and not directories so bPathInCache becomes false.
TBH I'm wondering how this works anywhere with directories.
My bet is it's stored slash at end and looked up without (or vice-versa).
the requested dir doesn't ends with slash. but since we are calling CDirectory::Exists here, I will try to add the end slash to the dir to see whether it can be fixed by this.
Fixed in: #2608