archive_sdmc.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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_backend.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 ArchiveBackend {
  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. std::string GetName() const override { return "SDMC"; }
  22. /**
  23. * Open a file specified by its path, using the specified mode
  24. * @param path Path relative to the archive
  25. * @param mode Mode to open the file with
  26. * @return Opened file, or nullptr
  27. */
  28. std::unique_ptr<File> OpenFile(const Path& path, const Mode mode) const override;
  29. /**
  30. * Delete a file specified by its path
  31. * @param path Path relative to the archive
  32. * @return Whether the file could be deleted
  33. */
  34. bool DeleteFile(const FileSys::Path& path) const override;
  35. /**
  36. * Rename a File specified by its path
  37. * @param src_path Source path relative to the archive
  38. * @param dest_path Destination path relative to the archive
  39. * @return Whether rename succeeded
  40. */
  41. bool RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const override;
  42. /**
  43. * Delete a directory specified by its path
  44. * @param path Path relative to the archive
  45. * @return Whether the directory could be deleted
  46. */
  47. bool DeleteDirectory(const FileSys::Path& path) const override;
  48. /**
  49. * Create a directory specified by its path
  50. * @param path Path relative to the archive
  51. * @return Whether the directory could be created
  52. */
  53. bool CreateDirectory(const Path& path) const override;
  54. /**
  55. * Rename a Directory specified by its path
  56. * @param src_path Source path relative to the archive
  57. * @param dest_path Destination path relative to the archive
  58. * @return Whether rename succeeded
  59. */
  60. bool RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const override;
  61. /**
  62. * Open a directory specified by its path
  63. * @param path Path relative to the archive
  64. * @return Opened directory, or nullptr
  65. */
  66. std::unique_ptr<Directory> OpenDirectory(const Path& path) const override;
  67. /**
  68. * Read data from the archive
  69. * @param offset Offset in bytes to start reading archive from
  70. * @param length Length in bytes to read data from archive
  71. * @param buffer Buffer to read data into
  72. * @return Number of bytes read
  73. */
  74. size_t Read(const u64 offset, const u32 length, u8* buffer) const override;
  75. /**
  76. * Write data to the archive
  77. * @param offset Offset in bytes to start writing data to
  78. * @param length Length in bytes of data to write to archive
  79. * @param buffer Buffer to write data from
  80. * @param flush The flush parameters (0 == do not flush)
  81. * @return Number of bytes written
  82. */
  83. size_t Write(const u64 offset, const u32 length, const u32 flush, u8* buffer) override;
  84. /**
  85. * Get the size of the archive in bytes
  86. * @return Size of the archive in bytes
  87. */
  88. size_t GetSize() const override;
  89. /**
  90. * Set the size of the archive in bytes
  91. */
  92. void SetSize(const u64 size) override;
  93. /**
  94. * Getter for the path used for this Archive
  95. * @return Mount point of that passthrough archive
  96. */
  97. std::string GetMountPoint() const;
  98. private:
  99. std::string mount_point;
  100. };
  101. } // namespace FileSys