savedata_factory.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_funcs.h"
  8. #include "common/common_types.h"
  9. #include "common/swap.h"
  10. #include "core/file_sys/vfs.h"
  11. #include "core/hle/result.h"
  12. namespace FileSys {
  13. enum class SaveDataSpaceId : u8 {
  14. NandSystem = 0,
  15. NandUser = 1,
  16. SdCardSystem = 2,
  17. TemporaryStorage = 3,
  18. SdCardUser = 4,
  19. ProperSystem = 100,
  20. };
  21. enum class SaveDataType : u8 {
  22. SystemSaveData = 0,
  23. SaveData = 1,
  24. BcatDeliveryCacheStorage = 2,
  25. DeviceSaveData = 3,
  26. TemporaryStorage = 4,
  27. CacheStorage = 5,
  28. };
  29. struct SaveDataDescriptor {
  30. u64_le title_id;
  31. u128 user_id;
  32. u64_le save_id;
  33. SaveDataType type;
  34. INSERT_PADDING_BYTES(7);
  35. u64_le zero_1;
  36. u64_le zero_2;
  37. u64_le zero_3;
  38. std::string DebugInfo() const;
  39. };
  40. static_assert(sizeof(SaveDataDescriptor) == 0x40, "SaveDataDescriptor has incorrect size.");
  41. /// File system interface to the SaveData archive
  42. class SaveDataFactory {
  43. public:
  44. explicit SaveDataFactory(VirtualDir dir);
  45. ~SaveDataFactory();
  46. ResultVal<VirtualDir> Open(SaveDataSpaceId space, SaveDataDescriptor meta);
  47. VirtualDir GetSaveDataSpaceDirectory(SaveDataSpaceId space) const;
  48. static std::string GetSaveDataSpaceIdPath(SaveDataSpaceId space);
  49. static std::string GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id,
  50. u128 user_id, u64 save_id);
  51. private:
  52. VirtualDir dir;
  53. };
  54. } // namespace FileSys