UpdaterCommon.h 1.2 KB

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