savedata_factory.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <memory>
  6. #include <string>
  7. #include "common/common_types.h"
  8. #include "core/file_sys/filesystem.h"
  9. #include "core/hle/result.h"
  10. namespace FileSys {
  11. enum class SaveDataSpaceId : u8 {
  12. NandSystem = 0,
  13. NandUser = 1,
  14. SdCard = 2,
  15. TemporaryStorage = 3,
  16. };
  17. enum class SaveDataType : u8 {
  18. SystemSaveData = 0,
  19. SaveData = 1,
  20. BcatDeliveryCacheStorage = 2,
  21. DeviceSaveData = 3,
  22. TemporaryStorage = 4,
  23. CacheStorage = 5,
  24. };
  25. struct SaveDataDescriptor {
  26. u64_le title_id;
  27. u128 user_id;
  28. u64_le save_id;
  29. SaveDataType type;
  30. INSERT_PADDING_BYTES(7);
  31. u64_le zero_1;
  32. u64_le zero_2;
  33. u64_le zero_3;
  34. std::string DebugInfo();
  35. };
  36. static_assert(sizeof(SaveDataDescriptor) == 0x40, "SaveDataDescriptor has incorrect size.");
  37. /// File system interface to the SaveData archive
  38. class SaveDataFactory {
  39. public:
  40. explicit SaveDataFactory(std::string nand_directory);
  41. ResultVal<std::unique_ptr<FileSystemBackend>> Open(SaveDataSpaceId space,
  42. SaveDataDescriptor meta);
  43. private:
  44. std::string nand_directory;
  45. std::string sd_directory;
  46. std::string GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id, u128 user_id,
  47. u64 save_id) const;
  48. };
  49. } // namespace FileSys