Debian Codegraph @

Source/Core/UpdaterCommon/UpdaterCommon.h

raw symbols SCIP
1 // Copyright 2019 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <array>
7 #include <cstdio>
8 #include <map>
9 #include <optional>
10 #include <string>
11 #include <vector>
12
13 #include "Common/CommonTypes.h"
14
15 // Refer to docs/autoupdate_overview.md for a detailed overview of the autoupdate process
16
17 struct Manifest
18 {
19 using Filename = std::string;
20 using Hash = std::array<u8, 16>;
21 std::map<Filename, Hash> entries;
22 };
23
24 // Represent the operations to be performed by the updater.
25 struct TodoList
26 {
27 struct DownloadOp
28 {
29 Manifest::Filename filename;
30 Manifest::Hash hash{};
31 };
32 std::vector<DownloadOp> to_download;
33
34 struct UpdateOp
35 {
36 Manifest::Filename filename;
37 std::optional<Manifest::Hash> old_hash;
38 Manifest::Hash new_hash{};
39 };
40 std::vector<UpdateOp> to_update;
41
42 struct DeleteOp
43 {
44 Manifest::Filename filename;
45 Manifest::Hash old_hash{};
46 };
47 std::vector<DeleteOp> to_delete;
48
49 void Log() const;
50 };
51
52 void LogToFile(const char* fmt, ...);
53 std::string HexEncode(const u8* buffer, size_t size);
54 Manifest::Hash ComputeHash(const std::string& contents);
55 bool RunUpdater(std::vector<std::string> args);