summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/file_sys/partition_filesystem.cpp7
-rw-r--r--src/core/file_sys/vfs_real.cpp7
2 files changed, 10 insertions, 4 deletions
diff --git a/src/core/file_sys/partition_filesystem.cpp b/src/core/file_sys/partition_filesystem.cpp
index 7ccca1089..fc37a40cc 100644
--- a/src/core/file_sys/partition_filesystem.cpp
+++ b/src/core/file_sys/partition_filesystem.cpp
@@ -2,7 +2,9 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <iterator>
5#include <utility> 6#include <utility>
7
6#include "common/file_util.h" 8#include "common/file_util.h"
7#include "common/logging/log.h" 9#include "common/logging/log.h"
8#include "core/file_sys/partition_filesystem.h" 10#include "core/file_sys/partition_filesystem.h"
@@ -99,11 +101,12 @@ void PartitionFilesystem::PrintDebugInfo() const {
99} 101}
100 102
101bool PartitionFilesystem::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) { 103bool PartitionFilesystem::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) {
102 auto iter = std::find(pfs_files.begin(), pfs_files.end(), file); 104 const auto iter = std::find(pfs_files.begin(), pfs_files.end(), file);
103 if (iter == pfs_files.end()) 105 if (iter == pfs_files.end())
104 return false; 106 return false;
105 107
106 pfs_files[iter - pfs_files.begin()] = pfs_files.back(); 108 const std::ptrdiff_t offset = std::distance(pfs_files.begin(), iter);
109 pfs_files[offset] = pfs_files.back();
107 pfs_files.pop_back(); 110 pfs_files.pop_back();
108 111
109 pfs_dirs.emplace_back(dir); 112 pfs_dirs.emplace_back(dir);
diff --git a/src/core/file_sys/vfs_real.cpp b/src/core/file_sys/vfs_real.cpp
index 22c858e0d..fa0df1bbe 100644
--- a/src/core/file_sys/vfs_real.cpp
+++ b/src/core/file_sys/vfs_real.cpp
@@ -2,6 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <iterator>
6
5#include "common/common_paths.h" 7#include "common/common_paths.h"
6#include "common/logging/log.h" 8#include "common/logging/log.h"
7#include "core/file_sys/vfs_real.h" 9#include "core/file_sys/vfs_real.h"
@@ -163,11 +165,12 @@ bool RealVfsDirectory::Rename(const std::string& name) {
163} 165}
164 166
165bool RealVfsDirectory::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) { 167bool RealVfsDirectory::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) {
166 auto iter = std::find(files.begin(), files.end(), file); 168 const auto iter = std::find(files.begin(), files.end(), file);
167 if (iter == files.end()) 169 if (iter == files.end())
168 return false; 170 return false;
169 171
170 files[iter - files.begin()] = files.back(); 172 const std::ptrdiff_t offset = std::distance(files.begin(), iter);
173 files[offset] = files.back();
171 files.pop_back(); 174 files.pop_back();
172 175
173 subdirectories.emplace_back(dir); 176 subdirectories.emplace_back(dir);