diff options
| -rw-r--r-- | windows/nsis-plugins/src/cleanup/cleaningops.cpp | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/windows/nsis-plugins/src/cleanup/cleaningops.cpp b/windows/nsis-plugins/src/cleanup/cleaningops.cpp index dd14b9035c..3a0764d91c 100644 --- a/windows/nsis-plugins/src/cleanup/cleaningops.cpp +++ b/windows/nsis-plugins/src/cleanup/cleaningops.cpp @@ -49,14 +49,16 @@ mirrored_range std::wstring ConstructLocalAppDataPath(const std::wstring &base, const std::wstring &user, const std::pair<std::vector<std::wstring>::iterator, std::vector<std::wstring>::iterator> &tokens) { - auto result = common::fs::MakePath(base, user); + auto path = std::experimental::filesystem::path(base); + + path.append(user); std::for_each(tokens.first, tokens.second, [&](const std::wstring &token) { - result = common::fs::MakePath(result, token); + path.append(token); }); - return result; + return path; } std::wstring GetSystemUserLocalAppData() @@ -71,7 +73,8 @@ std::wstring GetSystemUserLocalAppData() }; auto systemDir = common::fs::GetKnownFolderPath(FOLDERID_System, KF_FLAG_DEFAULT, NULL); - auto lsassPid = common::process::GetProcessIdFromName(common::fs::MakePath(systemDir, L"lsass.exe")); + auto lsassPath = std::experimental::filesystem::path(systemDir).append(L"lsass.exe"); + auto lsassPid = common::process::GetProcessIdFromName(lsassPath); auto processHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, lsassPid); @@ -106,9 +109,8 @@ namespace cleaningops void RemoveLogsCacheCurrentUser() { - auto localAppData = common::fs::GetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_DEFAULT, nullptr); - - auto appdir = common::fs::MakePath(localAppData, L"Mullvad VPN"); + const auto localAppData = common::fs::GetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_DEFAULT, nullptr); + const auto appdir = std::experimental::filesystem::path(localAppData).append(L"Mullvad VPN"); std::experimental::filesystem::remove_all(appdir); } @@ -178,26 +180,26 @@ void RemoveLogsCacheOtherUsers() while (files.next(file)) { - auto userLocalAppData = ConstructLocalAppDataPath(files.getDirectory(), file.cFileName, relativeLocalAppData); + const auto userLocalAppData = ConstructLocalAppDataPath(files.getDirectory(), file.cFileName, relativeLocalAppData); + const auto target = std::experimental::filesystem::path(userLocalAppData).append(L"Mullvad VPN"); std::error_code dummy; - std::experimental::filesystem::remove_all(common::fs::MakePath(userLocalAppData, L"Mullvad VPN"), dummy); + std::experimental::filesystem::remove_all(target, dummy); } } void RemoveLogsServiceUser() { - auto programData = common::fs::GetKnownFolderPath(FOLDERID_ProgramData, KF_FLAG_DEFAULT, nullptr); - - auto appdir = common::fs::MakePath(programData, L"Mullvad VPN"); + const auto programData = common::fs::GetKnownFolderPath(FOLDERID_ProgramData, KF_FLAG_DEFAULT, nullptr); + const auto appdir = std::experimental::filesystem::path(programData).append(L"Mullvad VPN"); std::experimental::filesystem::remove_all(appdir); } void RemoveCacheServiceUser() { - auto localAppData = GetSystemUserLocalAppData(); - auto mullvadAppData = common::fs::MakePath(localAppData, L"Mullvad VPN"); + const auto localAppData = GetSystemUserLocalAppData(); + const auto mullvadAppData = std::experimental::filesystem::path(localAppData).append(L"Mullvad VPN"); common::fs::ScopedNativeFileSystem nativeFileSystem; @@ -218,8 +220,10 @@ void RemoveCacheServiceUser() while (files.next(file)) { + const auto target = std::experimental::filesystem::path(files.getDirectory()).append(file.cFileName); + std::error_code dummy; - std::experimental::filesystem::remove(common::fs::MakePath(files.getDirectory(), file.cFileName), dummy); + std::experimental::filesystem::remove(target, dummy); } } @@ -232,8 +236,8 @@ void RemoveCacheServiceUser() void RemoveSettingsServiceUser() { - auto localAppData = GetSystemUserLocalAppData(); - auto mullvadAppData = common::fs::MakePath(localAppData, L"Mullvad VPN"); + const auto localAppData = GetSystemUserLocalAppData(); + const auto mullvadAppData = std::experimental::filesystem::path(localAppData).append(L"Mullvad VPN"); common::fs::ScopedNativeFileSystem nativeFileSystem; @@ -254,8 +258,10 @@ void RemoveSettingsServiceUser() while (files.next(file)) { + const auto target = std::experimental::filesystem::path(files.getDirectory()).append(file.cFileName); + std::error_code dummy; - std::experimental::filesystem::remove(common::fs::MakePath(files.getDirectory(), file.cFileName), dummy); + std::experimental::filesystem::remove(target, dummy); } } |
