summaryrefslogtreecommitdiffhomepage
path: root/windows
diff options
context:
space:
mode:
authorOdd Stranne <odd@mullvad.net>2018-09-03 17:15:40 +0200
committerOdd Stranne <odd@mullvad.net>2018-09-04 13:16:38 +0200
commit7b6932615ff0ea75bab3b7754eec2a94f8525538 (patch)
treedf6b29e9da4c62b6b13f43944337997e90bd80ab /windows
parentf670bb58ea0c9502bd61db87ebbbec512de49773 (diff)
downloadmullvadvpn-7b6932615ff0ea75bab3b7754eec2a94f8525538.tar.xz
mullvadvpn-7b6932615ff0ea75bab3b7754eec2a94f8525538.zip
Update code to use std::experimental::filesystem
Diffstat (limited to 'windows')
-rw-r--r--windows/nsis-plugins/src/cleanup/cleaningops.cpp42
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);
}
}