2019-02-25 15:08:03 -07:00
|
|
|
// Copyright 2019 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2019-02-25 15:08:03 -07:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <map>
|
|
|
|
#include <optional>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
|
2021-03-12 18:10:53 -07:00
|
|
|
// Refer to docs/autoupdate_overview.md for a detailed overview of the autoupdate process
|
|
|
|
|
2022-10-27 14:24:36 -06: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;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::string HexEncode(const u8* buffer, size_t size);
|
|
|
|
Manifest::Hash ComputeHash(const std::string& contents);
|
2019-03-03 05:56:54 -07:00
|
|
|
bool RunUpdater(std::vector<std::string> args);
|