summaryrefslogtreecommitdiff
path: root/src/mir_core
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_core
parent7997d0ec5810ad7699d0de6417510ab756be320d (diff)
DeleteDirectoryTreeW - new function that deletes a folder with all subfolders (recursively)
Diffstat (limited to 'src/mir_core')
-rw-r--r--src/mir_core/src/mir_core.def1
-rw-r--r--src/mir_core/src/mir_core64.def1
-rw-r--r--src/mir_core/src/path.cpp24
3 files changed, 26 insertions, 0 deletions
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index 1636bc0239..d0e17162d9 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -2,6 +2,7 @@ LIBRARY mir_core.mir
EXPORTS
?g_pCurrDb@@3PAVMDatabaseCommon@@A @1 NONAME
+DeleteDirectoryTreeW @2
CallFunctionAsync @5
CallPluginEventHook @7
CallService @8
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index bb77e99aac..797fb38dcd 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -2,6 +2,7 @@ LIBRARY mir_core.mir
EXPORTS
?g_pCurrDb@@3PEAVMDatabaseCommon@@EA @1 NONAME
+DeleteDirectoryTreeW @2
CallFunctionAsync @5
CallPluginEventHook @7
CallService @8
diff --git a/src/mir_core/src/path.cpp b/src/mir_core/src/path.cpp
index 99d95d9757..596eea39c4 100644
--- a/src/mir_core/src/path.cpp
+++ b/src/mir_core/src/path.cpp
@@ -207,6 +207,30 @@ MIR_CORE_DLL(int) CreateDirectoryTreeW(const wchar_t *szDir)
return (CreateDirectoryW(szTestDir, nullptr) == 0) ? GetLastError() : 0;
}
+MIR_CORE_DLL(int) DeleteDirectoryTreeW(const wchar_t *pwszDir, bool bAllowUndo)
+{
+ if (pwszDir == nullptr)
+ return ERROR_BAD_ARGUMENTS;
+
+ CMStringW wszPath(pwszDir);
+ wszPath.AppendChar(0);
+
+ SHFILEOPSTRUCTW file_op = {
+ nullptr,
+ FO_DELETE,
+ wszPath,
+ L"",
+ FOF_NOERRORUI | FOF_SILENT | FOF_NOCONFIRMATION,
+ false,
+ nullptr,
+ L"" };
+
+ if (bAllowUndo)
+ file_op.fFlags |= FOF_ALLOWUNDO;
+
+ return SHFileOperationW(&file_op);
+}
+
int InitPathUtils(void)
{
GetModuleFileNameA(nullptr, szMirandaPath, _countof(szMirandaPath));