diff options
Diffstat (limited to 'src/core/file_sys/vfs.cpp')
-rw-r--r-- | src/core/file_sys/vfs.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/core/file_sys/vfs.cpp b/src/core/file_sys/vfs.cpp index 84a6a7397..57d0aeb85 100644 --- a/src/core/file_sys/vfs.cpp +++ b/src/core/file_sys/vfs.cpp @@ -285,6 +285,27 @@ bool ReadOnlyVfsDirectory::Rename(std::string_view name) { return false; } +bool DeepEquals(const VirtualFile& file1, const VirtualFile& file2, size_t block_size) { + if (file1->GetSize() != file2->GetSize()) + return false; + + std::vector<u8> f1_v(block_size); + std::vector<u8> f2_v(block_size); + for (size_t i = 0; i < file1->GetSize(); i += block_size) { + auto f1_vs = file1->Read(f1_v.data(), block_size, i); + auto f2_vs = file2->Read(f2_v.data(), block_size, i); + + if (f1_vs != f2_vs) + return false; + for (size_t j = 0; j < f1_vs; ++j) { + if (f1_v[j] != f2_v[j]) + return false; + } + } + + return true; +} + bool VfsRawCopy(VirtualFile src, VirtualFile dest) { if (src == nullptr || dest == nullptr) return false; |