mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 14:05:42 +00:00
[RAPPS] Speed up app loading by caching the INI sections
This commit is contained in:
parent
6f9dd96dcf
commit
9bdeaca56e
6 changed files with 156 additions and 98 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue