summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-09-08 13:21:50 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-09-08 13:21:50 +0300
commit5d0dff54982b174d382aca8da00393273bc7b3e5 (patch)
treeb18df845cd408a8f4d32fe02e9e65109e01c58c0 /src/mir_app
parent7997d0ec5810ad7699d0de6417510ab756be320d (diff)
DeleteDirectoryTreeW - new function that deletes a folder with all subfolders (recursively)
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/db_ini.cpp15
-rw-r--r--src/mir_app/src/profilemanager.cpp24
2 files changed, 9 insertions, 30 deletions
diff --git a/src/mir_app/src/db_ini.cpp b/src/mir_app/src/db_ini.cpp
index 2580d8eb3d..f7122100e0 100644
--- a/src/mir_app/src/db_ini.cpp
+++ b/src/mir_app/src/db_ini.cpp
@@ -216,13 +216,7 @@ protected:
void Recycle_OnClick(CCtrlBase*)
{
- ptrW szIniPath(m_iniPath.GetText());
- SHFILEOPSTRUCT shfo = {};
- shfo.wFunc = FO_DELETE;
- shfo.pFrom = szIniPath;
- szIniPath[mir_wstrlen(szIniPath) + 1] = '\0';
- shfo.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO;
- SHFileOperation(&shfo);
+ DeleteDirectoryTreeW(ptrW(m_iniPath.GetText()), true);
Close();
}
@@ -553,12 +547,7 @@ static void DoAutoExec(void)
if (!mir_wstrcmpi(szOnCompletion, L"delete"))
DeleteFile(szIniPath);
else if (!mir_wstrcmpi(szOnCompletion, L"recycle")) {
- SHFILEOPSTRUCT shfo = {};
- shfo.wFunc = FO_DELETE;
- shfo.pFrom = szIniPath;
- szIniPath[mir_wstrlen(szIniPath) + 1] = 0;
- shfo.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO;
- SHFileOperation(&shfo);
+ DeleteDirectoryTreeW(szIniPath, true);
}
else if (!mir_wstrcmpi(szOnCompletion, L"rename")) {
wchar_t szRenamePrefix[MAX_PATH], szNewPath[MAX_PATH];
diff --git a/src/mir_app/src/profilemanager.cpp b/src/mir_app/src/profilemanager.cpp
index fc4912cf7b..96e802d6cf 100644
--- a/src/mir_app/src/profilemanager.cpp
+++ b/src/mir_app/src/profilemanager.cpp
@@ -84,14 +84,14 @@ class CCreateProfileDlg : public CDlgBase
int CreateProfile(const wchar_t *profile, DATABASELINK *link)
{
- wchar_t buf[256];
- int err = 0;
-
// check if the file already exists
const wchar_t *file = wcsrchr(profile, '\\');
if (file)
file++;
-
+
+ int err = 0;
+ wchar_t buf[256];
+
if (_waccess(profile, 0) == 0) {
// file already exists!
mir_snwprintf(buf,
@@ -101,12 +101,7 @@ class CCreateProfileDlg : public CDlgBase
return 0;
// move the file
- SHFILEOPSTRUCT sf = {};
- sf.wFunc = FO_DELETE;
- sf.pFrom = buf;
- sf.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO;
- mir_snwprintf(buf, L"%s\0", profile);
- if (SHFileOperation(&sf) != 0) {
+ if (DeleteDirectoryTreeW(profile, true) != 0) {
mir_snwprintf(buf, TranslateT("Couldn't move '%s' to the Recycle Bin. Please select another profile name."), file);
MessageBox(m_hwnd, buf, TranslateT("Problem moving profile"), MB_ICONINFORMATION | MB_OK);
return 0;
@@ -329,13 +324,8 @@ class CChooseProfileDlg : public CDlgBase
if (IDYES != MessageBoxW(nullptr, wszMessage, L"Miranda NG", MB_YESNO | MB_TASKMODAL | MB_ICONWARNING))
return;
- wszMessage.Format(L"%s\\%s%c", m_pd->ptszProfileDir, item.pszText, 0);
-
- SHFILEOPSTRUCT sf = {};
- sf.wFunc = FO_DELETE;
- sf.pFrom = wszMessage;
- sf.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_ALLOWUNDO;
- SHFileOperation(&sf);
+ wszMessage.Format(L"%s\\%s", m_pd->ptszProfileDir, item.pszText);
+ DeleteDirectoryTreeW(wszMessage, true);
m_profileList.DeleteItem(item.iItem);
}