From 0b891c9245f45825978f762af3812c9ae794ed7f Mon Sep 17 00:00:00 2001 From: Chloe Marcec Date: Mon, 6 Sep 2021 19:35:55 +1000 Subject: [PATCH 1/2] FS: Recursively create directories for CreateDirectory Originally we only created the parent directory, this caused issues for creating directories which also contained subdirectories, eg `/Folder1/Folder2` This allows the ultimate mod manager homebrew to at least boot --- .../hle/service/filesystem/filesystem.cpp | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index 4a9b13e45..14a491dd5 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp @@ -97,14 +97,19 @@ ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) cons ResultCode VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path_) const { std::string path(Common::FS::SanitizePath(path_)); - auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); - if (dir == nullptr || Common::FS::GetFilename(Common::FS::GetParentPath(path)).empty()) { - dir = backing; - } - auto new_dir = dir->CreateSubdirectory(Common::FS::GetFilename(path)); - if (new_dir == nullptr) { - // TODO(DarkLordZach): Find a better error code for this - return ResultUnknown; + const auto components = Common::FS::SplitPathComponents(path); + std::string relative_path = ""; + for (const auto& component : components) { + // Skip empty path components + if (component.empty()) { + continue; + } + relative_path = Common::FS::SanitizePath(relative_path + '/' + component); + auto new_dir = backing->CreateSubdirectory(relative_path); + if (new_dir == nullptr) { + // TODO(DarkLordZach): Find a better error code for this + return ResultUnknown; + } } return ResultSuccess; } From 005b0e68db603fbcbd0f2cdab722880d227d50ac Mon Sep 17 00:00:00 2001 From: Chloe <25727384+ogniK5377@users.noreply.github.com> Date: Thu, 9 Sep 2021 03:00:08 +1000 Subject: [PATCH 2/2] Addressed issues Co-authored-by: Mai M. --- src/core/hle/service/filesystem/filesystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index 14a491dd5..db17d61e4 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp @@ -98,7 +98,7 @@ ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) cons ResultCode VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path_) const { std::string path(Common::FS::SanitizePath(path_)); const auto components = Common::FS::SplitPathComponents(path); - std::string relative_path = ""; + std::string relative_path; for (const auto& component : components) { // Skip empty path components if (component.empty()) {