Skip to content
Snippets Groups Projects
Commit 8db3feae authored by Morph's avatar Morph
Browse files

filesystem: Fix CreateDirectory and DeleteFile

Add a check if dir is nullptr (does not exist)

Fixes save game creation in Hades
parent d291fc1a
No related branches found
No related tags found
No related merge requests found
...@@ -79,7 +79,7 @@ ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) cons ...@@ -79,7 +79,7 @@ ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) cons
} }
auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path));
if (dir->GetFile(Common::FS::GetFilename(path)) == nullptr) { if (dir == nullptr || dir->GetFile(Common::FS::GetFilename(path)) == nullptr) {
return FileSys::ERROR_PATH_NOT_FOUND; return FileSys::ERROR_PATH_NOT_FOUND;
} }
if (!dir->DeleteFile(Common::FS::GetFilename(path))) { if (!dir->DeleteFile(Common::FS::GetFilename(path))) {
...@@ -93,8 +93,9 @@ ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) cons ...@@ -93,8 +93,9 @@ ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) cons
ResultCode VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path_) const { ResultCode VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path_) const {
std::string path(Common::FS::SanitizePath(path_)); std::string path(Common::FS::SanitizePath(path_));
auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path));
if (dir == nullptr && Common::FS::GetFilename(Common::FS::GetParentPath(path)).empty()) if (dir == nullptr || Common::FS::GetFilename(Common::FS::GetParentPath(path)).empty()) {
dir = backing; dir = backing;
}
auto new_dir = dir->CreateSubdirectory(Common::FS::GetFilename(path)); auto new_dir = dir->CreateSubdirectory(Common::FS::GetFilename(path));
if (new_dir == nullptr) { if (new_dir == nullptr) {
// TODO(DarkLordZach): Find a better error code for this // TODO(DarkLordZach): Find a better error code for this
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment