[RAPPS] Speed up app loading by caching the INI sections

This commit is contained in:
Mark Jansen 2021-09-30 20:19:21 +02:00
parent 6f9dd96dcf
commit 9bdeaca56e
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
6 changed files with 156 additions and 98 deletions

View file

@ -140,17 +140,36 @@ BOOL StartProcess(const ATL::CStringW& Path, BOOL Wait)
BOOL GetStorageDirectory(ATL::CStringW& Directory)
{
LPWSTR DirectoryStr = Directory.GetBuffer(MAX_PATH);
if (!SHGetSpecialFolderPathW(NULL, DirectoryStr, CSIDL_LOCAL_APPDATA, TRUE))
static CStringW CachedDirectory;
static BOOL CachedDirectoryInitialized = FALSE;
if (!CachedDirectoryInitialized)
{
Directory.ReleaseBuffer();
return FALSE;
LPWSTR DirectoryStr = CachedDirectory.GetBuffer(MAX_PATH);
BOOL bHasPath = SHGetSpecialFolderPathW(NULL, DirectoryStr, CSIDL_LOCAL_APPDATA, TRUE);
if (bHasPath)
{
PathAppendW(DirectoryStr, L"rapps");
}
CachedDirectory.ReleaseBuffer();
if (bHasPath)
{
if (!CreateDirectoryW(CachedDirectory, NULL) && GetLastError() != ERROR_ALREADY_EXISTS)
{
CachedDirectory.Empty();
}
}
else
{
CachedDirectory.Empty();
}
CachedDirectoryInitialized = TRUE;
}
PathAppendW(DirectoryStr, L"rapps");
Directory.ReleaseBuffer();
return (CreateDirectoryW(Directory.GetString(), NULL) || GetLastError() == ERROR_ALREADY_EXISTS);
Directory = CachedDirectory;
return !Directory.IsEmpty();
}
VOID InitLogs()