archive_romfs.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 <vector>
  6. #include "common/common_types.h"
  7. #include "core/file_sys/archive_backend.h"
  8. #include "core/loader/loader.h"
  9. ////////////////////////////////////////////////////////////////////////////////////////////////////
  10. // FileSys namespace
  11. namespace FileSys {
  12. /// File system interface to the RomFS archive
  13. class Archive_RomFS final : public ArchiveBackend {
  14. public:
  15. Archive_RomFS(const Loader::AppLoader& app_loader);
  16. std::string GetName() const override { return "RomFS"; }
  17. /**
  18. * Open a file specified by its path, using the specified mode
  19. * @param path Path relative to the archive
  20. * @param mode Mode to open the file with
  21. * @return Opened file, or nullptr
  22. */
  23. std::unique_ptr<FileBackend> OpenFile(const Path& path, const Mode mode) const override;
  24. /**
  25. * Delete a file specified by its path
  26. * @param path Path relative to the archive
  27. * @return Whether the file could be deleted
  28. */
  29. bool DeleteFile(const Path& path) const override;
  30. /**
  31. * Rename a File specified by its path
  32. * @param src_path Source path relative to the archive
  33. * @param dest_path Destination path relative to the archive
  34. * @return Whether rename succeeded
  35. */
  36. bool RenameFile(const Path& src_path, const Path& dest_path) const override;
  37. /**
  38. * Delete a directory specified by its path
  39. * @param path Path relative to the archive
  40. * @return Whether the directory could be deleted
  41. */
  42. bool DeleteDirectory(const Path& path) const override;
  43. /**
  44. * Create a file specified by its path
  45. * @param path Path relative to the Archive
  46. * @param size The size of the new file, filled with zeroes
  47. * @return File creation result code
  48. */
  49. ResultCode CreateFile(const Path& path, u32 size) const override;
  50. /**
  51. * Create a directory specified by its path
  52. * @param path Path relative to the archive
  53. * @return Whether the directory could be created
  54. */
  55. bool CreateDirectory(const Path& path) const override;
  56. /**
  57. * Rename a Directory specified by its path
  58. * @param src_path Source path relative to the archive
  59. * @param dest_path Destination path relative to the archive
  60. * @return Whether rename succeeded
  61. */
  62. bool RenameDirectory(const Path& src_path, const Path& dest_path) const override;
  63. /**
  64. * Open a directory specified by its path
  65. * @param path Path relative to the archive
  66. * @return Opened directory, or nullptr
  67. */
  68. std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override;
  69. private:
  70. friend class File_RomFS;
  71. std::vector<u8> raw_data;
  72. };
  73. } // namespace FileSys