Skip to content

Instantly share code, notes, and snippets.

@zachhilman
Created June 28, 2018 03:35
Show Gist options
  • Save zachhilman/4b555737e325d05938e00e6169778b0e to your computer and use it in GitHub Desktop.
Save zachhilman/4b555737e325d05938e00e6169778b0e to your computer and use it in GitHub Desktop.
diff --git a/src/core/file_sys/vfs.cpp b/src/core/file_sys/vfs.cpp
index 82e8c604..a917fd0b 100644
--- a/src/core/file_sys/vfs.cpp
+++ b/src/core/file_sys/vfs.cpp
@@ -53,7 +53,8 @@ std::shared_ptr<VfsFile> VfsDirectory::GetFileRelative(const filesystem::path& p
return GetFile(path.filename().string());
auto parent = path.parent_path().string();
- parent.replace(path.root_path().string().begin(), path.root_path().string().end(), "");
+ auto root = path.root_path().string();
+ parent.replace(root.begin(), root.end(), "");
const auto index = parent.find_first_of('/');
const auto first_dir = parent.substr(0, index), rest = parent.substr(index + 1);
const auto sub = GetSubdirectory(first_dir);
@@ -75,13 +76,15 @@ std::shared_ptr<VfsDirectory> VfsDirectory::GetDirectoryRelative(
return GetSubdirectory(path.filename().string());
auto parent = path.parent_path().string();
- parent.replace(path.root_path().string().begin(), path.root_path().string().end(), "");
+ auto root_start = parent.find(path.root_path().string());
+ parent.replace(root_start, path.root_path().string().size(), "");
const auto index = parent.find_first_of('/');
- const auto first_dir = parent.substr(0, index), rest = parent.substr(index + 1);
+ const auto first_dir = parent.substr(0, index);
+ const auto rest = path.filename().string();
const auto sub = GetSubdirectory(first_dir);
if (sub == nullptr)
return nullptr;
- return sub->GetDirectoryRelative(path.root_path().string() + rest);
+ return sub->GetDirectoryRelative(path.root_path() / rest);
}
std::shared_ptr<VfsDirectory> VfsDirectory::GetDirectoryAbsolute(
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index e4dcd4d5..e9e26100 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -44,7 +44,11 @@ ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path) const
ResultCode VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path) const {
filesystem::path s_path(path);
+ auto a = s_path.parent_path();
auto dir = backing->GetDirectoryRelative(s_path.parent_path());
+ auto s = s_path.parent_path().filename().string();
+ if (dir == nullptr && s_path.parent_path().filename().string() == "")
+ dir = backing;
auto new_dir = dir->CreateSubdirectory(s_path.filename().string());
if (new_dir == nullptr)
return ResultCode(-1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment