ResultVal<std::shared_ptr<File>> OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path, const FileSys::Mode mode) { ArchiveBackend* archive = GetArchive(archive_handle); if (archive == nullptr) return ERR_INVALID_ARCHIVE_HANDLE; auto backend = archive->OpenFile(path, mode); if (backend.Failed()) return backend.Code(); auto file = std::shared_ptr<File>(new File(backend.MoveFrom(), path)); return MakeResult<std::shared_ptr<File>>(std::move(file)); }
ResultVal<Kernel::SharedPtr<File>> OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path, const FileSys::Mode mode) { ArchiveBackend* archive = GetArchive(archive_handle); if (archive == nullptr) return ERR_INVALID_HANDLE; std::unique_ptr<FileSys::FileBackend> backend = archive->OpenFile(path, mode); if (backend == nullptr) { return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound, ErrorLevel::Status); } auto file = Kernel::SharedPtr<File>(new File(std::move(backend), path)); return MakeResult<Kernel::SharedPtr<File>>(std::move(file)); }
std::tuple<ResultVal<std::shared_ptr<File>>, std::chrono::nanoseconds> ArchiveManager::OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path, const FileSys::Mode mode) { ArchiveBackend* archive = GetArchive(archive_handle); if (archive == nullptr) return std::make_tuple(FileSys::ERR_INVALID_ARCHIVE_HANDLE, static_cast<std::chrono::nanoseconds>(0)); std::chrono::nanoseconds open_timeout_ns{archive->GetOpenDelayNs()}; auto backend = archive->OpenFile(path, mode); if (backend.Failed()) return std::make_tuple(backend.Code(), open_timeout_ns); auto file = std::shared_ptr<File>(new File(system, std::move(backend).Unwrap(), path)); return std::make_tuple(MakeResult<std::shared_ptr<File>>(std::move(file)), open_timeout_ns); }