archive_sdmc.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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<FileBackend> 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<DirectoryBackend> OpenDirectory(const Path& path) const override;
  67. /**
  68. * Getter for the path used for this Archive
  69. * @return Mount point of that passthrough archive
  70. */
  71. std::string GetMountPoint() const;
  72. private:
  73. std::string mount_point;
  74. };
  75. } // namespace FileSys