Просмотр исходного кода

Merge pull request #4345 from Morph1984/fix-createfile

filesystem: Create subdirectories prior to creating a file
bunnei 6 лет назад
Родитель
Сommit
c700079e08
1 измененных файлов с 4 добавлено и 0 удалено
  1. 4 0
      src/core/hle/service/filesystem/filesystem.cpp

+ 4 - 0
src/core/hle/service/filesystem/filesystem.cpp

@@ -55,6 +55,10 @@ std::string VfsDirectoryServiceWrapper::GetName() const {
 ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size) const {
 ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size) const {
     std::string path(FileUtil::SanitizePath(path_));
     std::string path(FileUtil::SanitizePath(path_));
     auto dir = GetDirectoryRelativeWrapped(backing, FileUtil::GetParentPath(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));
+    }
     auto file = dir->CreateFile(FileUtil::GetFilename(path));
     auto file = dir->CreateFile(FileUtil::GetFilename(path));
     if (file == nullptr) {
     if (file == nullptr) {
         // TODO(DarkLordZach): Find a better error code for this
         // TODO(DarkLordZach): Find a better error code for this