Skip to content
Snippets Groups Projects
Commit 8f06a0f8 authored by Zach Hilman's avatar Zach Hilman
Browse files

vfs_real: Add CreateFullPath to Create* operations

parent dda8ef11
No related branches found
No related tags found
No related merge requests found
...@@ -83,12 +83,9 @@ VirtualFile RealVfsFilesystem::OpenFile(std::string_view path_, Mode perms) { ...@@ -83,12 +83,9 @@ VirtualFile RealVfsFilesystem::OpenFile(std::string_view path_, Mode perms) {
VirtualFile RealVfsFilesystem::CreateFile(std::string_view path_, Mode perms) { VirtualFile RealVfsFilesystem::CreateFile(std::string_view path_, Mode perms) {
const auto path = FileUtil::SanitizePath(path_, FileUtil::DirectorySeparator::PlatformDefault); const auto path = FileUtil::SanitizePath(path_, FileUtil::DirectorySeparator::PlatformDefault);
if (!FileUtil::Exists(path)) const auto path_fwd = FileUtil::SanitizePath(path, FileUtil::DirectorySeparator::ForwardSlash);
return nullptr; if (!FileUtil::Exists(path) && !FileUtil::CreateFullPath(path_fwd) &&
if (!FileUtil::CreateFullPath( !FileUtil::CreateEmptyFile(path))
FileUtil::SanitizePath(path, FileUtil::DirectorySeparator::ForwardSlash)))
return nullptr;
if (!FileUtil::CreateEmptyFile(path))
return nullptr; return nullptr;
return OpenFile(path, perms); return OpenFile(path, perms);
} }
...@@ -145,12 +142,9 @@ VirtualDir RealVfsFilesystem::OpenDirectory(std::string_view path_, Mode perms) ...@@ -145,12 +142,9 @@ VirtualDir RealVfsFilesystem::OpenDirectory(std::string_view path_, Mode perms)
VirtualDir RealVfsFilesystem::CreateDirectory(std::string_view path_, Mode perms) { VirtualDir RealVfsFilesystem::CreateDirectory(std::string_view path_, Mode perms) {
const auto path = FileUtil::SanitizePath(path_, FileUtil::DirectorySeparator::PlatformDefault); const auto path = FileUtil::SanitizePath(path_, FileUtil::DirectorySeparator::PlatformDefault);
if (!FileUtil::Exists(path)) const auto path_fwd = FileUtil::SanitizePath(path, FileUtil::DirectorySeparator::ForwardSlash);
return nullptr; if (!FileUtil::Exists(path) && !FileUtil::CreateFullPath(path_fwd) &&
if (!FileUtil::CreateFullPath( !FileUtil::CreateEmptyFile(path))
FileUtil::SanitizePath(path, FileUtil::DirectorySeparator::ForwardSlash)))
return nullptr;
if (!FileUtil::CreateDir(path))
return nullptr; return nullptr;
// Cannot use make_shared as RealVfsDirectory constructor is private // Cannot use make_shared as RealVfsDirectory constructor is private
return std::shared_ptr<RealVfsDirectory>(new RealVfsDirectory(*this, path, perms)); return std::shared_ptr<RealVfsDirectory>(new RealVfsDirectory(*this, path, perms));
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#pragma once #pragma once
#include <string_view> #include <string_view>
#include <boost/container/flat_map.hpp> #include <boost/container/flat_map.hpp>
#include "common/file_util.h" #include "common/file_util.h"
#include "core/file_sys/mode.h" #include "core/file_sys/mode.h"
......
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