[FS] Archive::OpenArchive returns Result<T, E> now

This commit is contained in:
wheremyfoodat 2023-05-14 19:31:51 +03:00
parent 37fb660c7f
commit 0b0d6dcf4b
12 changed files with 25 additions and 24 deletions

View file

@ -129,11 +129,11 @@ std::optional<Handle> FSService::openArchiveHandle(u32 archiveID, const FSPath&
return std::nullopt;
}
bool opened = archive->openArchive(path);
if (opened) {
Rust::Result<ArchiveBase*, FSResult> res = archive->openArchive(path);
if (res.isOk()) {
auto handle = kernel.makeObject(KernelObjectType::Archive);
auto& archiveObject = kernel.getObjects()[handle];
archiveObject.data = new ArchiveSession(archive, path);
archiveObject.data = new ArchiveSession(res.unwrap(), path);
return handle;
}
@ -334,10 +334,11 @@ void FSService::openFileDirectly(u32 messagePointer) {
auto filePath = readPath(filePathType, filePathPointer, filePathSize);
const FilePerms perms(openFlags);
archive = archive->openArchive(archivePath);
if (archive == nullptr) [[unlikely]] {
Rust::Result<ArchiveBase*, FSResult> res = archive->openArchive(archivePath);
if (res.isErr()) [[unlikely]] {
Helpers::panic("OpenFileDirectly: Failed to open archive with given path");
}
archive = res.unwrap();
std::optional<Handle> handle = openFileHandle(archive, filePath, archivePath, perms);
mem.write32(messagePointer, IPC::responseHeader(0x803, 1, 2));