https://git.reactos.org/?p=reactos.git;a=commitdiff;h=26da451ba5c0581f33f9d…
commit 26da451ba5c0581f33f9d6c0226f604253c782be
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Sun Sep 6 23:14:37 2020 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Oct 11 17:01:05 2020 +0200
[RAPPS] Delete icons and temp screenshot when cleaning up the db
---
base/applications/rapps/available.cpp | 50 ++++++++++++++++++++++++++---------
1 file changed, 38 insertions(+), 12 deletions(-)
diff --git a/base/applications/rapps/available.cpp
b/base/applications/rapps/available.cpp
index 897251321f6..89f4ec5a255 100644
--- a/base/applications/rapps/available.cpp
+++ b/base/applications/rapps/available.cpp
@@ -342,26 +342,52 @@ VOID CAvailableApps::FreeCachedEntries()
m_InfoList.RemoveAll();
}
-VOID CAvailableApps::DeleteCurrentAppsDB()
+static void DeleteWithWildcard(const CStringW& DirWithFilter)
{
HANDLE hFind = INVALID_HANDLE_VALUE;
WIN32_FIND_DATAW FindFileData;
- hFind = FindFirstFileW(m_Strings.szSearchPath.GetString(), &FindFileData);
+ hFind = FindFirstFileW(DirWithFilter, &FindFileData);
- if (hFind != INVALID_HANDLE_VALUE)
+ if (hFind == INVALID_HANDLE_VALUE)
+ return;
+
+ CStringW Dir = DirWithFilter;
+ PathRemoveFileSpecW(Dir.GetBuffer(MAX_PATH));
+ Dir.ReleaseBuffer();
+
+ do
{
- ATL::CStringW szTmp;
- do
+ ATL::CStringW szTmp = Dir + L"\\";
+ szTmp += FindFileData.cFileName;
+
+ if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
- szTmp = m_Strings.szAppsPath;
- PathAppendW(szTmp.GetBuffer(MAX_PATH), FindFileData.cFileName);
- szTmp.ReleaseBuffer();
- DeleteFileW(szTmp.GetString());
- } while (FindNextFileW(hFind, &FindFileData) != 0);
- FindClose(hFind);
- }
+ DeleteFileW(szTmp);
+ }
+ } while (FindNextFileW(hFind, &FindFileData) != 0);
+ FindClose(hFind);
+}
+
+VOID CAvailableApps::DeleteCurrentAppsDB()
+{
+ // Delete icons
+ ATL::CStringW IconPath = m_Strings.szAppsPath;
+ PathAppendW(IconPath.GetBuffer(MAX_PATH), L"icons");
+ IconPath.ReleaseBuffer();
+ DeleteWithWildcard(IconPath + L"\\*.ico");
+
+ // Delete leftover screenshots
+ ATL::CStringW ScrnshotFolder = m_Strings.szAppsPath;
+ PathAppendW(ScrnshotFolder.GetBuffer(MAX_PATH), L"screenshots");
+ ScrnshotFolder.ReleaseBuffer();
+ DeleteWithWildcard(IconPath + L"\\*.tmp");
+
+ // Delete data base files (*.txt)
+ DeleteWithWildcard(m_Strings.szSearchPath);
+ RemoveDirectoryW(IconPath);
+ RemoveDirectoryW(ScrnshotFolder);
RemoveDirectoryW(m_Strings.szAppsPath);
RemoveDirectoryW(m_Strings.szPath);
}