From 7f908ceb00786a2cfdbc10aefdecbce265b99527 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Wed, 15 Jul 2020 12:16:31 -0400 Subject: [PATCH 1/2] filesystem: Create subdirectories prior to creating a file If subdirectories exist in the given path parameter and don't exist in the real filesystem create them prior to creating the files within. This fixes the softlocks upon save creation in The Legend of Zelda: Breath of the Wild --- src/core/hle/service/filesystem/filesystem.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index cadc038050..3020101a13 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp @@ -55,6 +55,9 @@ std::string VfsDirectoryServiceWrapper::GetName() const { ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size) const { std::string path(FileUtil::SanitizePath(path_)); auto dir = GetDirectoryRelativeWrapped(backing, FileUtil::GetParentPath(path)); + if (dir == nullptr) { + dir = backing->CreateSubdirectory(FileUtil::GetParentPath(path)); + } auto file = dir->CreateFile(FileUtil::GetFilename(path)); if (file == nullptr) { // TODO(DarkLordZach): Find a better error code for this From 6bba209bbaea7406106f22eda83aa16266b978a9 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Wed, 15 Jul 2020 13:08:04 -0400 Subject: [PATCH 2/2] Add comment to clarify the nullptr check --- src/core/hle/service/filesystem/filesystem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index 3020101a13..c661249980 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp @@ -55,6 +55,7 @@ std::string VfsDirectoryServiceWrapper::GetName() const { ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size) const { std::string path(FileUtil::SanitizePath(path_)); auto dir = GetDirectoryRelativeWrapped(backing, FileUtil::GetParentPath(path)); + // dir can be nullptr if path contains subdirectories, create those prior to creating the file. if (dir == nullptr) { dir = backing->CreateSubdirectory(FileUtil::GetParentPath(path)); }