archive_romfs.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  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.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 Archive {
  14. public:
  15. Archive_RomFS(const Loader::AppLoader& app_loader);
  16. ~Archive_RomFS() override;
  17. /**
  18. * Get the IdCode of the archive (e.g. RomFS, SaveData, etc.)
  19. * @return IdCode of the archive
  20. */
  21. IdCode GetIdCode() const override { return IdCode::RomFS; }
  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. * Create a directory specified by its path
  31. * @param path Path relative to the archive
  32. * @return Whether the directory could be created
  33. */
  34. bool CreateDirectory(const Path& path) const override;
  35. /**
  36. * Open a directory specified by its path
  37. * @param path Path relative to the archive
  38. * @return Opened directory, or nullptr
  39. */
  40. std::unique_ptr<Directory> OpenDirectory(const Path& path) const override;
  41. /**
  42. * Read data from the archive
  43. * @param offset Offset in bytes to start reading data from
  44. * @param length Length in bytes of data to read from archive
  45. * @param buffer Buffer to read data into
  46. * @return Number of bytes read
  47. */
  48. size_t Read(const u64 offset, const u32 length, u8* buffer) const override;
  49. /**
  50. * Write data to the archive
  51. * @param offset Offset in bytes to start writing data to
  52. * @param length Length in bytes of data to write to archive
  53. * @param buffer Buffer to write data from
  54. * @param flush The flush parameters (0 == do not flush)
  55. * @return Number of bytes written
  56. */
  57. size_t Write(const u64 offset, const u32 length, const u32 flush, u8* buffer) override;
  58. /**
  59. * Get the size of the archive in bytes
  60. * @return Size of the archive in bytes
  61. */
  62. size_t GetSize() const override;
  63. /**
  64. * Set the size of the archive in bytes
  65. */
  66. void SetSize(const u64 size) override;
  67. private:
  68. std::vector<u8> raw_data;
  69. };
  70. } // namespace FileSys