aboutsummaryrefslogtreecommitdiff
path: root/src/core/file_sys/vfs_real.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-08-15 23:11:58 -0400
committerGitHub <noreply@github.com>2018-08-15 23:11:58 -0400
commit960f4ecce2a2ff452fe911d8973e4830b3a6af0a (patch)
tree3814f831fd8207598c342341e56997a0b3123cd0 /src/core/file_sys/vfs_real.cpp
parentd08f54b77dece80938d5774e31cf87373d6da6de (diff)
parent3781654c6d5f0932351f020b884ac6ff32cbc7e9 (diff)
Merge pull request #1005 from DarkLordZach/registered-fmt
file_sys: Add support for registration format
Diffstat (limited to 'src/core/file_sys/vfs_real.cpp')
-rw-r--r--src/core/file_sys/vfs_real.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/core/file_sys/vfs_real.cpp b/src/core/file_sys/vfs_real.cpp
index 1b59197374..0afe515f07 100644
--- a/src/core/file_sys/vfs_real.cpp
+++ b/src/core/file_sys/vfs_real.cpp
@@ -83,8 +83,12 @@ VirtualFile RealVfsFilesystem::OpenFile(std::string_view path_, Mode perms) {
VirtualFile RealVfsFilesystem::CreateFile(std::string_view path_, Mode perms) {
const auto path = FileUtil::SanitizePath(path_, FileUtil::DirectorySeparator::PlatformDefault);
- if (!FileUtil::Exists(path) && !FileUtil::CreateEmptyFile(path))
- return nullptr;
+ const auto path_fwd = FileUtil::SanitizePath(path, FileUtil::DirectorySeparator::ForwardSlash);
+ if (!FileUtil::Exists(path)) {
+ FileUtil::CreateFullPath(path_fwd);
+ if (!FileUtil::CreateEmptyFile(path))
+ return nullptr;
+ }
return OpenFile(path, perms);
}
@@ -140,8 +144,12 @@ VirtualDir RealVfsFilesystem::OpenDirectory(std::string_view path_, Mode perms)
VirtualDir RealVfsFilesystem::CreateDirectory(std::string_view path_, Mode perms) {
const auto path = FileUtil::SanitizePath(path_, FileUtil::DirectorySeparator::PlatformDefault);
- if (!FileUtil::Exists(path) && !FileUtil::CreateDir(path))
- return nullptr;
+ const auto path_fwd = FileUtil::SanitizePath(path, FileUtil::DirectorySeparator::ForwardSlash);
+ if (!FileUtil::Exists(path)) {
+ FileUtil::CreateFullPath(path_fwd);
+ if (!FileUtil::CreateDir(path))
+ return nullptr;
+ }
// Cannot use make_shared as RealVfsDirectory constructor is private
return std::shared_ptr<RealVfsDirectory>(new RealVfsDirectory(*this, path, perms));
}
@@ -306,14 +314,14 @@ RealVfsDirectory::RealVfsDirectory(RealVfsFilesystem& base_, const std::string&
std::shared_ptr<VfsFile> RealVfsDirectory::GetFileRelative(std::string_view path) const {
const auto full_path = FileUtil::SanitizePath(this->path + DIR_SEP + std::string(path));
- if (!FileUtil::Exists(full_path))
+ if (!FileUtil::Exists(full_path) || FileUtil::IsDirectory(full_path))
return nullptr;
return base.OpenFile(full_path, perms);
}
std::shared_ptr<VfsDirectory> RealVfsDirectory::GetDirectoryRelative(std::string_view path) const {
const auto full_path = FileUtil::SanitizePath(this->path + DIR_SEP + std::string(path));
- if (!FileUtil::Exists(full_path))
+ if (!FileUtil::Exists(full_path) || !FileUtil::IsDirectory(full_path))
return nullptr;
return base.OpenDirectory(full_path, perms);
}