summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-01-09 18:36:39 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-01-09 18:36:39 +0300
commit6058db4dbc4f0f7627bac09a49a775d1953c428c (patch)
treee230141020da62549aa2d1f7c64afdd1b142d4ec /src
parentbb939d4b38daf85a2707217a7f9af272e0756cc8 (diff)
more thorough fix for #2992
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/db_ini.cpp10
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
-rw-r--r--src/mir_app/src/pu_utils.cpp16
4 files changed, 20 insertions, 8 deletions
diff --git a/src/mir_app/src/db_ini.cpp b/src/mir_app/src/db_ini.cpp
index c920716303..a164e9eb83 100644
--- a/src/mir_app/src/db_ini.cpp
+++ b/src/mir_app/src/db_ini.cpp
@@ -36,14 +36,8 @@ static void MyDeleteFile(const wchar_t *pwszFileName)
static void ToRecycleBin(const wchar_t *pwszFileName)
{
- CMStringW tmpPath(pwszFileName);
- tmpPath.AppendChar(0);
-
- SHFILEOPSTRUCT shfo = {};
- shfo.wFunc = FO_DELETE;
- shfo.pFrom = tmpPath;
- shfo.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO;
- SHFileOperation(&shfo);
+ if (PU::PrepareEscalation())
+ PU::SafeRecycleBin(pwszFileName);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 484658e218..575fe053e1 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -789,3 +789,4 @@ _Netlib_SslShutdown@4 @876 NONAME
_Netlib_SslWrite@12 @877 NONAME
?AllowTyping@CSrmmBaseDialog@@IBE_NXZ @878 NONAME
?setTyping@CSrmmBaseDialog@@QAEXHPBUUSERINFO@@@Z @879 NONAME
+?SafeRecycleBin@PU@@YGHPB_W@Z @880 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index babafe60b3..f867e78aa7 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -789,3 +789,4 @@ Netlib_SslShutdown @876 NONAME
Netlib_SslWrite @877 NONAME
?AllowTyping@CSrmmBaseDialog@@IEBA_NXZ @878 NONAME
?setTyping@CSrmmBaseDialog@@QEAAXHPEBUUSERINFO@@@Z @879 NONAME
+?SafeRecycleBin@PU@@YAHPEB_W@Z @880 NONAME
diff --git a/src/mir_app/src/pu_utils.cpp b/src/mir_app/src/pu_utils.cpp
index 64666c2912..3851b4d949 100644
--- a/src/mir_app/src/pu_utils.cpp
+++ b/src/mir_app/src/pu_utils.cpp
@@ -269,6 +269,22 @@ MIR_APP_DLL(int) PU::SafeDeleteFile(const wchar_t *pwszFile)
return TransactPipe(3, pwszFile, nullptr);
}
+MIR_APP_DLL(int) PU::SafeRecycleBin(const wchar_t *pwszFile)
+{
+ if (g_hPipe == nullptr) {
+ CMStringW tmpPath(pwszFile);
+ tmpPath.AppendChar(0);
+
+ SHFILEOPSTRUCT shfo = {};
+ shfo.wFunc = FO_DELETE;
+ shfo.pFrom = tmpPath;
+ shfo.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO;
+ return SHFileOperation(&shfo);
+ }
+
+ return TransactPipe(7, pwszFile, nullptr);
+}
+
MIR_APP_DLL(int) PU::SafeCreateDirectory(const wchar_t *pwszFolder)
{
if (g_hPipe == nullptr)