mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-02 21:36:20 +12:00
ExtSaveData work
This commit is contained in:
parent
902b877c40
commit
995dfb81df
12 changed files with 68 additions and 28 deletions
|
@ -39,12 +39,13 @@ ArchiveBase* FSService::getArchiveFromID(u32 id) {
|
|||
}
|
||||
}
|
||||
|
||||
std::optional<Handle> FSService::openFileHandle(ArchiveBase* archive, const FSPath& path) {
|
||||
bool opened = archive->openFile(path);
|
||||
if (opened) {
|
||||
std::optional<Handle> FSService::openFileHandle(ArchiveBase* archive, const FSPath& path, const FilePerms& perms) {
|
||||
FileDescriptor opened = archive->openFile(path, perms);
|
||||
if (opened.has_value()) { // If opened doesn't have a value, we failed to open the file
|
||||
auto handle = kernel.makeObject(KernelObjectType::File);
|
||||
|
||||
auto& file = kernel.getObjects()[handle];
|
||||
file.data = new FileSession(archive, path);
|
||||
file.data = new FileSession(archive, path, opened.value());
|
||||
|
||||
return handle;
|
||||
} else {
|
||||
|
@ -164,8 +165,9 @@ void FSService::openFile(u32 messagePointer) {
|
|||
|
||||
ArchiveBase* archive = archiveObject->getData<ArchiveSession>()->archive;
|
||||
auto filePath = readPath(filePathType, filePathPointer, filePathSize);
|
||||
const FilePerms perms(openFlags);
|
||||
|
||||
std::optional<Handle> handle = openFileHandle(archive, filePath);
|
||||
std::optional<Handle> handle = openFileHandle(archive, filePath, perms);
|
||||
if (!handle.has_value()) {
|
||||
printf("OpenFile failed\n");
|
||||
mem.write32(messagePointer + 4, Result::FileNotFound);
|
||||
|
@ -196,13 +198,14 @@ void FSService::openFileDirectly(u32 messagePointer) {
|
|||
|
||||
auto archivePath = readPath(archivePathType, archivePathPointer, archivePathSize);
|
||||
auto filePath = readPath(filePathType, filePathPointer, filePathSize);
|
||||
const FilePerms perms(openFlags);
|
||||
|
||||
archive = archive->openArchive(archivePath);
|
||||
if (archive == nullptr) [[unlikely]] {
|
||||
Helpers::panic("OpenFileDirectly: Failed to open archive with given path");
|
||||
}
|
||||
|
||||
std::optional<Handle> handle = openFileHandle(archive, filePath);
|
||||
std::optional<Handle> handle = openFileHandle(archive, filePath, perms);
|
||||
if (!handle.has_value()) {
|
||||
Helpers::panic("OpenFileDirectly: Failed to open file with given path");
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue