2019-02-25 22:08:03 +00:00
|
|
|
// Copyright 2019 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2019-02-25 22:08:03 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <map>
|
|
|
|
#include <optional>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
|
2021-03-13 01:10:53 +00:00
|
|
|
// Refer to docs/autoupdate_overview.md for a detailed overview of the autoupdate process
|
|
|
|
|
2022-10-27 20:24:36 +00:00
|
|
|
struct Manifest
|
|
|
|
{
|
|
|
|
using Filename = std::string;
|
|
|
|
using Hash = std::array<u8, 16>;
|
|
|
|
std::map<Filename, Hash> entries;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Represent the operations to be performed by the updater.
|
|
|
|
struct TodoList
|
|
|
|
{
|
|
|
|
struct DownloadOp
|
|
|
|
{
|
|
|
|
Manifest::Filename filename;
|
|
|
|
Manifest::Hash hash{};
|
|
|
|
};
|
|
|
|
std::vector<DownloadOp> to_download;
|
|
|
|
|
|
|
|
struct UpdateOp
|
|
|
|
{
|
|
|
|
Manifest::Filename filename;
|
|
|
|
std::optional<Manifest::Hash> old_hash;
|
|
|
|
Manifest::Hash new_hash{};
|
|
|
|
};
|
|
|
|
std::vector<UpdateOp> to_update;
|
|
|
|
|
|
|
|
struct DeleteOp
|
|
|
|
{
|
|
|
|
Manifest::Filename filename;
|
|
|
|
Manifest::Hash old_hash{};
|
|
|
|
};
|
|
|
|
std::vector<DeleteOp> to_delete;
|
|
|
|
|
|
|
|
void Log() const;
|
|
|
|
};
|
|
|
|
|
2023-03-10 02:18:09 +00:00
|
|
|
void LogToFile(const char* fmt, ...);
|
2022-10-27 20:24:36 +00:00
|
|
|
std::string HexEncode(const u8* buffer, size_t size);
|
|
|
|
Manifest::Hash ComputeHash(const std::string& contents);
|
2019-03-03 12:56:54 +00:00
|
|
|
bool RunUpdater(std::vector<std::string> args);
|