archive_romfs.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <algorithm>
  5. #include <memory>
  6. #include "common/common_types.h"
  7. #include "common/logging/log.h"
  8. #include "common/make_unique.h"
  9. #include "core/file_sys/archive_romfs.h"
  10. #include "core/file_sys/ivfc_archive.h"
  11. ////////////////////////////////////////////////////////////////////////////////////////////////////
  12. // FileSys namespace
  13. namespace FileSys {
  14. ArchiveFactory_RomFS::ArchiveFactory_RomFS(Loader::AppLoader& app_loader) {
  15. // Load the RomFS from the app
  16. if (Loader::ResultStatus::Success != app_loader.ReadRomFS(romfs_file, data_offset, data_size)) {
  17. LOG_ERROR(Service_FS, "Unable to read RomFS!");
  18. }
  19. }
  20. ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_RomFS::Open(const Path& path) {
  21. auto archive = Common::make_unique<IVFCArchive>(romfs_file, data_offset, data_size);
  22. return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
  23. }
  24. ResultCode ArchiveFactory_RomFS::Format(const Path& path) {
  25. LOG_ERROR(Service_FS, "Attempted to format a RomFS archive.");
  26. // TODO: Verify error code
  27. return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS,
  28. ErrorSummary::NotSupported, ErrorLevel::Permanent);
  29. }
  30. } // namespace FileSys