diff options
| author | 2020-12-11 20:22:01 -0500 | |
|---|---|---|
| committer | 2020-12-11 20:24:22 -0500 | |
| commit | 8941cdb7d2355ba0f3084b306165923520f9db65 (patch) | |
| tree | a3a2c67a83080b4693096474852d8b72a1a95c4c /src/common/file_util.cpp | |
| parent | Revert "Merge pull request #5176 from Morph1984/fix-createfile" (diff) | |
| download | yuzu-8941cdb7d2355ba0f3084b306165923520f9db65.tar.gz yuzu-8941cdb7d2355ba0f3084b306165923520f9db65.tar.xz yuzu-8941cdb7d2355ba0f3084b306165923520f9db65.zip | |
Revert "Merge pull request #5174 from ReinUsesLisp/fs-fix"
This reverts commit 5fe55b16a11d9ec607fb8a3fdddc77a4393cd96a, reversing
changes made to e94dd7e2c4fc3f7ca2c15c01bdc301be2b8a4c1b.
Diffstat (limited to 'src/common/file_util.cpp')
| -rw-r--r-- | src/common/file_util.cpp | 30 |
1 files changed, 2 insertions, 28 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 7752c0421..d5f6ea2ee 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp | |||
| @@ -98,11 +98,6 @@ bool Delete(const fs::path& path) { | |||
| 98 | bool CreateDir(const fs::path& path) { | 98 | bool CreateDir(const fs::path& path) { |
| 99 | LOG_TRACE(Common_Filesystem, "directory {}", path.string()); | 99 | LOG_TRACE(Common_Filesystem, "directory {}", path.string()); |
| 100 | 100 | ||
| 101 | if (Exists(path)) { | ||
| 102 | LOG_DEBUG(Common_Filesystem, "path exists {}", path.string()); | ||
| 103 | return true; | ||
| 104 | } | ||
| 105 | |||
| 106 | std::error_code ec; | 101 | std::error_code ec; |
| 107 | const bool success = fs::create_directory(path, ec); | 102 | const bool success = fs::create_directory(path, ec); |
| 108 | 103 | ||
| @@ -114,41 +109,20 @@ bool CreateDir(const fs::path& path) { | |||
| 114 | return true; | 109 | return true; |
| 115 | } | 110 | } |
| 116 | 111 | ||
| 117 | bool CreateDirs(const fs::path& path) { | 112 | bool CreateFullPath(const fs::path& path) { |
| 118 | LOG_TRACE(Common_Filesystem, "path {}", path.string()); | 113 | LOG_TRACE(Common_Filesystem, "path {}", path.string()); |
| 119 | 114 | ||
| 120 | if (Exists(path)) { | ||
| 121 | LOG_DEBUG(Common_Filesystem, "path exists {}", path.string()); | ||
| 122 | return true; | ||
| 123 | } | ||
| 124 | |||
| 125 | std::error_code ec; | 115 | std::error_code ec; |
| 126 | const bool success = fs::create_directories(path, ec); | 116 | const bool success = fs::create_directories(path, ec); |
| 127 | 117 | ||
| 128 | if (!success) { | 118 | if (!success) { |
| 129 | LOG_ERROR(Common_Filesystem, "Unable to create directories: {}", ec.message()); | 119 | LOG_ERROR(Common_Filesystem, "Unable to create full path: {}", ec.message()); |
| 130 | return false; | 120 | return false; |
| 131 | } | 121 | } |
| 132 | 122 | ||
| 133 | return true; | 123 | return true; |
| 134 | } | 124 | } |
| 135 | 125 | ||
| 136 | bool CreateFullPath(const fs::path& path) { | ||
| 137 | LOG_TRACE(Common_Filesystem, "path {}", path); | ||
| 138 | |||
| 139 | // Removes trailing slashes and turns any '\' into '/' | ||
| 140 | const auto new_path = SanitizePath(path.string(), DirectorySeparator::ForwardSlash); | ||
| 141 | |||
| 142 | if (new_path.rfind('.') == std::string::npos) { | ||
| 143 | // The path is a directory | ||
| 144 | return CreateDirs(new_path); | ||
| 145 | } else { | ||
| 146 | // The path is a file | ||
| 147 | // Creates directory preceding the last '/' | ||
| 148 | return CreateDirs(new_path.substr(0, new_path.rfind('/'))); | ||
| 149 | } | ||
| 150 | } | ||
| 151 | |||
| 152 | bool Rename(const fs::path& src, const fs::path& dst) { | 126 | bool Rename(const fs::path& src, const fs::path& dst) { |
| 153 | LOG_TRACE(Common_Filesystem, "{} --> {}", src.string(), dst.string()); | 127 | LOG_TRACE(Common_Filesystem, "{} --> {}", src.string(), dst.string()); |
| 154 | 128 | ||