| 1 |
|
| 2 |
|
| 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 |
|
| 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 |
|
| 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); |