file_romfs.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #include "common/common_types.h"
  5. #include "core/file_sys/file_romfs.h"
  6. #include "core/file_sys/archive_romfs.h"
  7. ////////////////////////////////////////////////////////////////////////////////////////////////////
  8. // FileSys namespace
  9. namespace FileSys {
  10. /**
  11. * Open the file
  12. * @return true if the file opened correctly
  13. */
  14. bool File_RomFS::Open() {
  15. return true;
  16. }
  17. /**
  18. * Read data from the file
  19. * @param offset Offset in bytes to start reading data from
  20. * @param length Length in bytes of data to read from file
  21. * @param buffer Buffer to read data into
  22. * @return Number of bytes read
  23. */
  24. size_t File_RomFS::Read(const u64 offset, const u32 length, u8* buffer) const {
  25. LOG_TRACE(Service_FS, "called offset=%llu, length=%d", offset, length);
  26. memcpy(buffer, &archive->raw_data[(u32)offset], length);
  27. return length;
  28. }
  29. /**
  30. * Write data to the file
  31. * @param offset Offset in bytes to start writing data to
  32. * @param length Length in bytes of data to write to file
  33. * @param flush The flush parameters (0 == do not flush)
  34. * @param buffer Buffer to read data from
  35. * @return Number of bytes written
  36. */
  37. size_t File_RomFS::Write(const u64 offset, const u32 length, const u32 flush, const u8* buffer) const {
  38. LOG_WARNING(Service_FS, "Attempted to write to ROMFS.");
  39. return 0;
  40. }
  41. /**
  42. * Get the size of the file in bytes
  43. * @return Size of the file in bytes
  44. */
  45. size_t File_RomFS::GetSize() const {
  46. return sizeof(u8) * archive->raw_data.size();
  47. }
  48. /**
  49. * Set the size of the file in bytes
  50. * @param size New size of the file
  51. * @return true if successful
  52. */
  53. bool File_RomFS::SetSize(const u64 size) const {
  54. LOG_WARNING(Service_FS, "Attempted to set the size of ROMFS");
  55. return false;
  56. }
  57. /**
  58. * Close the file
  59. * @return true if the file closed correctly
  60. */
  61. bool File_RomFS::Close() const {
  62. return false;
  63. }
  64. } // namespace FileSys