file_romfs.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/file_backend.h"
  7. #include "core/loader/loader.h"
  8. ////////////////////////////////////////////////////////////////////////////////////////////////////
  9. // FileSys namespace
  10. namespace FileSys {
  11. class Archive_RomFS;
  12. class File_RomFS final : public FileBackend {
  13. public:
  14. File_RomFS(const Archive_RomFS* archive) : archive(archive) {}
  15. /**
  16. * Open the file
  17. * @return true if the file opened correctly
  18. */
  19. bool Open() override;
  20. /**
  21. * Read data from the file
  22. * @param offset Offset in bytes to start reading data from
  23. * @param length Length in bytes of data to read from file
  24. * @param buffer Buffer to read data into
  25. * @return Number of bytes read
  26. */
  27. size_t Read(const u64 offset, const u32 length, u8* buffer) const override;
  28. /**
  29. * Write data to the file
  30. * @param offset Offset in bytes to start writing data to
  31. * @param length Length in bytes of data to write to file
  32. * @param flush The flush parameters (0 == do not flush)
  33. * @param buffer Buffer to read data from
  34. * @return Number of bytes written
  35. */
  36. size_t Write(const u64 offset, const u32 length, const u32 flush, const u8* buffer) const override;
  37. /**
  38. * Get the size of the file in bytes
  39. * @return Size of the file in bytes
  40. */
  41. size_t GetSize() const override;
  42. /**
  43. * Set the size of the file in bytes
  44. * @param size New size of the file
  45. * @return true if successful
  46. */
  47. bool SetSize(const u64 size) const override;
  48. /**
  49. * Close the file
  50. * @return true if the file closed correctly
  51. */
  52. bool Close() const override;
  53. private:
  54. const Archive_RomFS* archive;
  55. };
  56. } // namespace FileSys