archive_sdmc.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common_types.h"
  6. #include "core/file_sys/archive.h"
  7. #include "core/loader/loader.h"
  8. ////////////////////////////////////////////////////////////////////////////////////////////////////
  9. // FileSys namespace
  10. namespace FileSys {
  11. /// File system interface to the SDMC archive
  12. class Archive_SDMC final : public Archive {
  13. public:
  14. Archive_SDMC(const std::string& mount_point);
  15. ~Archive_SDMC() override;
  16. /**
  17. * Initialize the archive.
  18. * @return true if it initialized successfully
  19. */
  20. bool Initialize();
  21. /**
  22. * Get the IdCode of the archive (e.g. RomFS, SaveData, etc.)
  23. * @return IdCode of the archive
  24. */
  25. IdCode GetIdCode() const override { return IdCode::SDMC; };
  26. /**
  27. * Open a file specified by its path, using the specified mode
  28. * @param path Path relative to the archive
  29. * @param mode Mode to open the file with
  30. * @return Opened file, or nullptr
  31. */
  32. std::unique_ptr<File> OpenFile(const Path& path, const Mode mode) const override;
  33. /**
  34. * Create a directory specified by its path
  35. * @param path Path relative to the archive
  36. * @return Whether the directory could be created
  37. */
  38. bool CreateDirectory(const Path& path) const override;
  39. /**
  40. * Open a directory specified by its path
  41. * @param path Path relative to the archive
  42. * @return Opened directory, or nullptr
  43. */
  44. std::unique_ptr<Directory> OpenDirectory(const Path& path) const override;
  45. /**
  46. * Read data from the archive
  47. * @param offset Offset in bytes to start reading archive from
  48. * @param length Length in bytes to read data from archive
  49. * @param buffer Buffer to read data into
  50. * @return Number of bytes read
  51. */
  52. size_t Read(const u64 offset, const u32 length, u8* buffer) const override;
  53. /**
  54. * Write data to the archive
  55. * @param offset Offset in bytes to start writing data to
  56. * @param length Length in bytes of data to write to archive
  57. * @param buffer Buffer to write data from
  58. * @param flush The flush parameters (0 == do not flush)
  59. * @return Number of bytes written
  60. */
  61. size_t Write(const u64 offset, const u32 length, const u32 flush, u8* buffer) override;
  62. /**
  63. * Get the size of the archive in bytes
  64. * @return Size of the archive in bytes
  65. */
  66. size_t GetSize() const override;
  67. /**
  68. * Set the size of the archive in bytes
  69. */
  70. void SetSize(const u64 size) override;
  71. /**
  72. * Getter for the path used for this Archive
  73. * @return Mount point of that passthrough archive
  74. */
  75. std::string GetMountPoint() const;
  76. private:
  77. std::string mount_point;
  78. };
  79. } // namespace FileSys