Skip to content

Commit eb27810

Browse files
committed
✨ Delete backups folder
can be owned by admin fixes #4
1 parent c758b29 commit eb27810

5 files changed

Lines changed: 79 additions & 2 deletions

File tree

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ add_executable(
2828
Artifact.hpp
2929
Version.hpp
3030
Versions.hpp
31+
artifacts/BackupsFolder.cpp
32+
artifacts/BackupsFolder.hpp
3133
artifacts/BasicMSIArtifact.cpp
3234
artifacts/BasicMSIArtifact.hpp
3335
artifacts/DCSHooks.cpp

src/artifacts/BackupsFolder.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2025 Fred Emmott <fred@fredemmott.com>
2+
// SPDX-License-Identifier: MIT
3+
#include "BackupsFolder.hpp"
4+
5+
#include <Windows.h>
6+
#include <shlobj_core.h>
7+
#include <wil/resource.h>
8+
9+
#include <FredEmmott/GUI.hpp>
10+
#include <memory>
11+
12+
#include "Versions.hpp"
13+
14+
namespace {
15+
std::filesystem::path GetPathForConstructor() {
16+
wil::unique_hlocal_string path;
17+
if (FAILED(SHGetKnownFolderPath(
18+
FOLDERID_LocalAppData, 0, nullptr, std::out_ptr(path)))) {
19+
return {};
20+
}
21+
const auto ret
22+
= std::filesystem::path {std::wstring_view {path.get()}} / L"OpenKneeboard Backups";
23+
if (!std::filesystem::exists(ret)) {
24+
return {};
25+
}
26+
return ret;
27+
}
28+
}// namespace
29+
30+
BackupsFolder::BackupsFolder()
31+
: FilesystemArtifact(GetPathForConstructor()) {}
32+
33+
std::string_view BackupsFolder::GetTitle() const {
34+
return "Settings Backups";
35+
}
36+
37+
void BackupsFolder::DrawCardContent() const {
38+
namespace fuii = FredEmmott::GUI::Immediate;
39+
fuii::Label("Found in {}", GetPath().string());
40+
}
41+
42+
Version BackupsFolder::GetEarliestVersion() const {
43+
return Versions::v1_10;
44+
}
45+
46+
std::optional<Version> BackupsFolder::GetRemovedVersion() const {
47+
return std::nullopt;
48+
}
49+
Artifact::Kind BackupsFolder::GetKind() const {
50+
return Kind::UserSettings;
51+
}

src/artifacts/BackupsFolder.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2025 Fred Emmott <fred@fredemmott.com>
2+
// SPDX-License-Identifier: MIT
3+
#pragma once
4+
5+
#include <filesystem>
6+
7+
#include "Artifact.hpp"
8+
#include "FilesystemArtifact.hpp"
9+
10+
class BackupsFolder final : public FilesystemArtifact {
11+
public:
12+
BackupsFolder();
13+
~BackupsFolder() override = default;
14+
[[nodiscard]] std::string_view GetTitle() const override;
15+
void DrawCardContent() const override;
16+
[[nodiscard]] Version GetEarliestVersion() const override;
17+
[[nodiscard]] std::optional<Version> GetRemovedVersion() const override;
18+
Kind GetKind() const override;
19+
20+
private:
21+
std::filesystem::path mPath;
22+
};

src/artifacts/LogsFolder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LogsFolder::LogsFolder()
3131
: FilesystemArtifact(GetPathForConstructor()) {}
3232

3333
std::string_view LogsFolder::GetTitle() const {
34-
return "Logs in Local App Data";
34+
return "Logs or crash dumps";
3535
}
3636

3737
void LogsFolder::DrawCardContent() const {

src/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
#include <future>
1111
#include <ranges>
1212

13+
#include "artifacts/BackupsFolder.hpp"
1314
#include "artifacts/DCSHooks.hpp"
1415
#include "artifacts/HKCULayer.hpp"
1516
#include "artifacts/HKLMLayer.hpp"
1617
#include "artifacts/LocalAppDataSettings.hpp"
18+
#include "artifacts/LogsFolder.hpp"
1719
#include "artifacts/MSIInstallation.hpp"
1820
#include "artifacts/MSIXInstallation.hpp"
1921
#include "artifacts/MultipleMSIInstallations.hpp"
20-
#include "artifacts/LogsFolder.hpp"
2122
#include "artifacts/ProgramData.hpp"
2223
#include "artifacts/SavedGamesSettings.hpp"
2324
#include "config.hpp"
@@ -161,6 +162,7 @@ auto& GetArtifacts() {
161162
std::make_unique<SavedGamesSettings>(),
162163
std::make_unique<LocalAppDataSettings>(),
163164
std::make_unique<LogsFolder>(),
165+
std::make_unique<BackupsFolder>(),
164166
};
165167
for (auto&& it: artifacts) {
166168
if (!it->IsPresent()) {

0 commit comments

Comments
 (0)