summaryrefslogtreecommitdiffstats
path: root/src/common/file_util.cpp
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2020-12-12 02:21:21 +0100
committerMorph <39850852+Morph1984@users.noreply.github.com>2020-12-12 02:21:21 +0100
commitac3ec5ed132a8d8b63c4e95205521addb90fdd0f (patch)
treeef746996baf604e05dd7a0b04659de722a280eba /src/common/file_util.cpp
parentMerge pull request #5181 from Morph1984/5174-review (diff)
downloadyuzu-ac3ec5ed132a8d8b63c4e95205521addb90fdd0f.tar
yuzu-ac3ec5ed132a8d8b63c4e95205521addb90fdd0f.tar.gz
yuzu-ac3ec5ed132a8d8b63c4e95205521addb90fdd0f.tar.bz2
yuzu-ac3ec5ed132a8d8b63c4e95205521addb90fdd0f.tar.lz
yuzu-ac3ec5ed132a8d8b63c4e95205521addb90fdd0f.tar.xz
yuzu-ac3ec5ed132a8d8b63c4e95205521addb90fdd0f.tar.zst
yuzu-ac3ec5ed132a8d8b63c4e95205521addb90fdd0f.zip
Diffstat (limited to 'src/common/file_util.cpp')
-rw-r--r--src/common/file_util.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 8e061ff6c..a286b9341 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -136,10 +136,16 @@ bool CreateDirs(const fs::path& path) {
bool CreateFullPath(const fs::path& path) {
LOG_TRACE(Common_Filesystem, "path {}", path);
- if (path.has_extension()) {
- return CreateDirs(path.parent_path());
+ // Removes trailing slashes and turns any '\' into '/'
+ const auto new_path = SanitizePath(path.string(), DirectorySeparator::ForwardSlash);
+
+ if (new_path.rfind('.') == std::string::npos) {
+ // The path is a directory
+ return CreateDirs(new_path);
} else {
- return CreateDirs(path);
+ // The path is a file
+ // Creates directory preceding the last '/'
+ return CreateDirs(new_path.substr(0, new_path.rfind('/')));
}
}