summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2015-12-27 22:18:43 +0100
committerbunnei <bunneidev@gmail.com>2015-12-27 22:18:43 +0100
commit40599c24eada83d5c8a3defba4fc409dcd994a7e (patch)
tree9f01bab7ba96db23475abb738d8e3648ec642b79 /src
parentMerge pull request #1287 from lioncash/memory (diff)
parentAdd missing return values in ForeachDirectoryEntry (diff)
downloadyuzu-40599c24eada83d5c8a3defba4fc409dcd994a7e.tar
yuzu-40599c24eada83d5c8a3defba4fc409dcd994a7e.tar.gz
yuzu-40599c24eada83d5c8a3defba4fc409dcd994a7e.tar.bz2
yuzu-40599c24eada83d5c8a3defba4fc409dcd994a7e.tar.lz
yuzu-40599c24eada83d5c8a3defba4fc409dcd994a7e.tar.xz
yuzu-40599c24eada83d5c8a3defba4fc409dcd994a7e.tar.zst
yuzu-40599c24eada83d5c8a3defba4fc409dcd994a7e.zip
Diffstat (limited to 'src')
-rw-r--r--src/common/file_util.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 4c7113390..052c0ecd6 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -427,6 +427,9 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directo
// How many files + directories we found
unsigned found_entries = 0;
+ // Save the status of callback function
+ bool callback_error = false;
+
#ifdef _WIN32
// Find the first file in the directory.
WIN32_FIND_DATA ffd;
@@ -455,8 +458,10 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directo
continue;
unsigned ret_entries;
- if (!callback(&ret_entries, directory, virtual_name))
+ if (!callback(&ret_entries, directory, virtual_name)) {
+ callback_error = true;
break;
+ }
found_entries += ret_entries;
#ifdef _WIN32
@@ -467,9 +472,14 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directo
closedir(dirp);
#endif
- // num_entries_out is allowed to be specified nullptr, in which case we shouldn't try to set it
- if (num_entries_out != nullptr)
- *num_entries_out = found_entries;
+ if (!callback_error) {
+ // num_entries_out is allowed to be specified nullptr, in which case we shouldn't try to set it
+ if (num_entries_out != nullptr)
+ *num_entries_out = found_entries;
+ return true;
+ } else {
+ return false;
+ }
}
unsigned ScanDirectoryTree(const std::string &directory, FSTEntry& parent_entry)