diff options
| author | 2018-08-13 01:43:35 -0400 | |
|---|---|---|
| committer | 2018-08-13 01:43:35 -0400 | |
| commit | e67630b51e5f453fea5bc6825e4c1a43d9306cf9 (patch) | |
| tree | 58148af1f7e3a043c499807d98dad02ef6264cf9 | |
| parent | Merge pull request #1031 from lioncash/verbosity (diff) | |
| parent | vfs: Use sanitized paths within MoveFile() and MoveDirectory() (diff) | |
| download | yuzu-e67630b51e5f453fea5bc6825e4c1a43d9306cf9.tar.gz yuzu-e67630b51e5f453fea5bc6825e4c1a43d9306cf9.tar.xz yuzu-e67630b51e5f453fea5bc6825e4c1a43d9306cf9.zip | |
Merge pull request #1032 from lioncash/sanitize
vfs: Use sanitized paths within MoveFile() and MoveDirectory()
| -rw-r--r-- | src/core/file_sys/vfs.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/core/file_sys/vfs.cpp b/src/core/file_sys/vfs.cpp index 24e158962..a5ec50b1a 100644 --- a/src/core/file_sys/vfs.cpp +++ b/src/core/file_sys/vfs.cpp | |||
| @@ -74,15 +74,15 @@ VirtualFile VfsFilesystem::CopyFile(std::string_view old_path_, std::string_view | |||
| 74 | return new_file; | 74 | return new_file; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | VirtualFile VfsFilesystem::MoveFile(std::string_view old_path_, std::string_view new_path_) { | 77 | VirtualFile VfsFilesystem::MoveFile(std::string_view old_path, std::string_view new_path) { |
| 78 | const auto old_path = FileUtil::SanitizePath(old_path_); | 78 | const auto sanitized_old_path = FileUtil::SanitizePath(old_path); |
| 79 | const auto new_path = FileUtil::SanitizePath(new_path_); | 79 | const auto sanitized_new_path = FileUtil::SanitizePath(new_path); |
| 80 | 80 | ||
| 81 | // Again, non-default impls are highly encouraged to provide a more optimized version of this. | 81 | // Again, non-default impls are highly encouraged to provide a more optimized version of this. |
| 82 | auto out = CopyFile(old_path_, new_path_); | 82 | auto out = CopyFile(sanitized_old_path, sanitized_new_path); |
| 83 | if (out == nullptr) | 83 | if (out == nullptr) |
| 84 | return nullptr; | 84 | return nullptr; |
| 85 | if (DeleteFile(old_path)) | 85 | if (DeleteFile(sanitized_old_path)) |
| 86 | return out; | 86 | return out; |
| 87 | return nullptr; | 87 | return nullptr; |
| 88 | } | 88 | } |
| @@ -137,15 +137,15 @@ VirtualDir VfsFilesystem::CopyDirectory(std::string_view old_path_, std::string_ | |||
| 137 | return new_dir; | 137 | return new_dir; |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | VirtualDir VfsFilesystem::MoveDirectory(std::string_view old_path_, std::string_view new_path_) { | 140 | VirtualDir VfsFilesystem::MoveDirectory(std::string_view old_path, std::string_view new_path) { |
| 141 | const auto old_path = FileUtil::SanitizePath(old_path_); | 141 | const auto sanitized_old_path = FileUtil::SanitizePath(old_path); |
| 142 | const auto new_path = FileUtil::SanitizePath(new_path_); | 142 | const auto sanitized_new_path = FileUtil::SanitizePath(new_path); |
| 143 | 143 | ||
| 144 | // Non-default impls are highly encouraged to provide a more optimized version of this. | 144 | // Non-default impls are highly encouraged to provide a more optimized version of this. |
| 145 | auto out = CopyDirectory(old_path_, new_path_); | 145 | auto out = CopyDirectory(sanitized_old_path, sanitized_new_path); |
| 146 | if (out == nullptr) | 146 | if (out == nullptr) |
| 147 | return nullptr; | 147 | return nullptr; |
| 148 | if (DeleteDirectory(old_path)) | 148 | if (DeleteDirectory(sanitized_old_path)) |
| 149 | return out; | 149 | return out; |
| 150 | return nullptr; | 150 | return nullptr; |
| 151 | } | 151 | } |