From f79400bdcfdade258a9070de2b9a433c86cac588 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 9 Jan 2022 20:54:59 +0300 Subject: fix for moving autoexec_* files --- src/mir_app/src/db_ini.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mir_app/src/db_ini.cpp b/src/mir_app/src/db_ini.cpp index a164e9eb83..99096afb50 100644 --- a/src/mir_app/src/db_ini.cpp +++ b/src/mir_app/src/db_ini.cpp @@ -28,6 +28,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static bool bModuleInitialized = false; static HANDLE hIniChangeNotification; +static void MyMoveFile(const wchar_t *pwszFrom, const wchar_t *pwszTo) +{ + if (PU::PrepareEscalation()) + PU::SafeMoveFile(pwszFrom, pwszTo); +} + static void MyDeleteFile(const wchar_t *pwszFileName) { if (PU::PrepareEscalation()) @@ -233,7 +239,7 @@ protected: void Move_OnClick(CCtrlBase*) { - MoveFile(ptrW(m_iniPath.GetText()), ptrW(m_newPath.GetText())); + MyMoveFile(ptrW(m_iniPath.GetText()), ptrW(m_newPath.GetText())); Close(); } @@ -559,12 +565,10 @@ static void DoAutoExec(void) ToRecycleBin(szIniPath); } else if (!mir_wstrcmpi(szOnCompletion, L"rename")) { - wchar_t szRenamePrefix[MAX_PATH], szNewPath[MAX_PATH]; - Profile_GetSetting(L"AutoExec/RenamePrefix", szRenamePrefix, L"done_"); - mir_wstrcpy(szNewPath, szFindPath); - mir_wstrcat(szNewPath, szRenamePrefix); - mir_wstrcat(szNewPath, fd.cFileName); - MoveFile(szIniPath, szNewPath); + wchar_t wszRenamePrefix[MAX_PATH], wszNewPath[MAX_PATH]; + Profile_GetSetting(L"AutoExec/RenamePrefix", wszRenamePrefix, L"done_"); + mir_snwprintf(wszNewPath, L"%s%s%s", szFindPath, wszRenamePrefix, fd.cFileName); + MyMoveFile(szIniPath, wszNewPath); } else if (!mir_wstrcmpi(szOnCompletion, L"ask")) { CIniImportDoneDlg dlg(szIniPath); -- cgit v1.2.3