savedata_factory.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 "common/swap.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() const;
  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(VirtualDir dir);
  41. ResultVal<VirtualDir> Open(SaveDataSpaceId space, SaveDataDescriptor meta);
  42. private:
  43. VirtualDir dir;
  44. std::string GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id, u128 user_id,
  45. u64 save_id) const;
  46. };
  47. } // namespace FileSys