savedata_factory.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. SdCard = 2,
  17. TemporaryStorage = 3,
  18. };
  19. enum class SaveDataType : u8 {
  20. SystemSaveData = 0,
  21. SaveData = 1,
  22. BcatDeliveryCacheStorage = 2,
  23. DeviceSaveData = 3,
  24. TemporaryStorage = 4,
  25. CacheStorage = 5,
  26. };
  27. struct SaveDataDescriptor {
  28. u64_le title_id;
  29. u128 user_id;
  30. u64_le save_id;
  31. SaveDataType type;
  32. INSERT_PADDING_BYTES(7);
  33. u64_le zero_1;
  34. u64_le zero_2;
  35. u64_le zero_3;
  36. std::string DebugInfo() const;
  37. };
  38. static_assert(sizeof(SaveDataDescriptor) == 0x40, "SaveDataDescriptor has incorrect size.");
  39. /// File system interface to the SaveData archive
  40. class SaveDataFactory {
  41. public:
  42. explicit SaveDataFactory(VirtualDir dir);
  43. ~SaveDataFactory();
  44. ResultVal<VirtualDir> Open(SaveDataSpaceId space, SaveDataDescriptor meta);
  45. static std::string GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id,
  46. u128 user_id, u64 save_id);
  47. private:
  48. VirtualDir dir;
  49. };
  50. } // namespace FileSys