archive_romfs.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #include <memory>
  5. #include "common/common_types.h"
  6. #include "common/make_unique.h"
  7. #include "core/file_sys/archive_romfs.h"
  8. #include "core/file_sys/directory_romfs.h"
  9. #include "core/file_sys/file_romfs.h"
  10. ////////////////////////////////////////////////////////////////////////////////////////////////////
  11. // FileSys namespace
  12. namespace FileSys {
  13. Archive_RomFS::Archive_RomFS(const Loader::AppLoader& app_loader) {
  14. // Load the RomFS from the app
  15. if (Loader::ResultStatus::Success != app_loader.ReadRomFS(raw_data)) {
  16. LOG_ERROR(Service_FS, "Unable to read RomFS!");
  17. }
  18. }
  19. /**
  20. * Open a file specified by its path, using the specified mode
  21. * @param path Path relative to the archive
  22. * @param mode Mode to open the file with
  23. * @return Opened file, or nullptr
  24. */
  25. std::unique_ptr<FileBackend> Archive_RomFS::OpenFile(const Path& path, const Mode mode) const {
  26. return Common::make_unique<File_RomFS>(this);
  27. }
  28. /**
  29. * Delete a file specified by its path
  30. * @param path Path relative to the archive
  31. * @return Whether the file could be deleted
  32. */
  33. bool Archive_RomFS::DeleteFile(const FileSys::Path& path) const {
  34. LOG_WARNING(Service_FS, "Attempted to delete a file from ROMFS.");
  35. return false;
  36. }
  37. bool Archive_RomFS::RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const {
  38. LOG_WARNING(Service_FS, "Attempted to rename a file within ROMFS.");
  39. return false;
  40. }
  41. /**
  42. * Delete a directory specified by its path
  43. * @param path Path relative to the archive
  44. * @return Whether the directory could be deleted
  45. */
  46. bool Archive_RomFS::DeleteDirectory(const FileSys::Path& path) const {
  47. LOG_WARNING(Service_FS, "Attempted to delete a directory from ROMFS.");
  48. return false;
  49. }
  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 Archive_RomFS::CreateDirectory(const Path& path) const {
  56. LOG_WARNING(Service_FS, "Attempted to create a directory in ROMFS.");
  57. return false;
  58. }
  59. bool Archive_RomFS::RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const {
  60. LOG_WARNING(Service_FS, "Attempted to rename a file within ROMFS.");
  61. return false;
  62. }
  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> Archive_RomFS::OpenDirectory(const Path& path) const {
  69. return Common::make_unique<Directory_RomFS>();
  70. }
  71. } // namespace FileSys