archive_extsavedata.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright 2014 Citra Emulator Project
  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/archive_backend.h"
  9. #include "core/hle/result.h"
  10. ////////////////////////////////////////////////////////////////////////////////////////////////////
  11. // FileSys namespace
  12. namespace FileSys {
  13. /// File system interface to the ExtSaveData archive
  14. class ArchiveFactory_ExtSaveData final : public ArchiveFactory {
  15. public:
  16. ArchiveFactory_ExtSaveData(const std::string& mount_point, bool shared);
  17. /**
  18. * Initialize the archive.
  19. * @return true if it initialized successfully
  20. */
  21. bool Initialize();
  22. std::string GetName() const override { return "ExtSaveData"; }
  23. ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path) override;
  24. ResultCode Format(const Path& path) override;
  25. const std::string& GetMountPoint() const { return mount_point; }
  26. private:
  27. /**
  28. * This holds the full directory path for this archive, it is only set after a successful call
  29. * to Open, this is formed as <base extsavedatapath>/<type>/<high>/<low>.
  30. * See GetExtSaveDataPath for the code that extracts this data from an archive path.
  31. */
  32. std::string mount_point;
  33. };
  34. /**
  35. * Constructs a path to the concrete ExtData archive in the host filesystem based on the
  36. * input Path and base mount point.
  37. * @param mount_point The base mount point of the ExtSaveData archives.
  38. * @param path The path that identifies the requested concrete ExtSaveData archive.
  39. * @returns The complete path to the specified extdata archive in the host filesystem
  40. */
  41. std::string GetExtSaveDataPath(const std::string& mount_point, const Path& path);
  42. /**
  43. * Constructs a path to the base folder to hold concrete ExtSaveData archives in the host file system.
  44. * @param mount_point The base folder where this folder resides, ie. SDMC or NAND.
  45. * @param shared Whether this ExtSaveData container is for SharedExtSaveDatas or not.
  46. * @returns The path to the base ExtSaveData archives' folder in the host file system
  47. */
  48. std::string GetExtDataContainerPath(const std::string& mount_point, bool shared);
  49. /**
  50. * Constructs a FileSys::Path object that refers to the ExtData archive identified by
  51. * the specified media type, high save id and low save id.
  52. * @param media_type The media type where the archive is located (NAND / SDMC)
  53. * @param high The high word of the save id for the archive
  54. * @param low The low word of the save id for the archive
  55. * @returns A FileSys::Path to the wanted archive
  56. */
  57. Path ConstructExtDataBinaryPath(u32 media_type, u32 high, u32 low);
  58. } // namespace FileSys