mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-30 10:42:47 +01:00
Add missing return values in ForeachDirectoryEntry
ForeachDirectoryEntry is changed by #1256 ,but return value at last line was missing.
This commit is contained in:
parent
ed20141346
commit
8376821776
1 changed files with 14 additions and 4 deletions
|
@ -427,6 +427,9 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directo
|
||||||
// How many files + directories we found
|
// How many files + directories we found
|
||||||
unsigned found_entries = 0;
|
unsigned found_entries = 0;
|
||||||
|
|
||||||
|
// Save the status of callback function
|
||||||
|
bool callback_error = false;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Find the first file in the directory.
|
// Find the first file in the directory.
|
||||||
WIN32_FIND_DATA ffd;
|
WIN32_FIND_DATA ffd;
|
||||||
|
@ -455,8 +458,10 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directo
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
unsigned ret_entries;
|
unsigned ret_entries;
|
||||||
if (!callback(&ret_entries, directory, virtual_name))
|
if (!callback(&ret_entries, directory, virtual_name)) {
|
||||||
|
callback_error = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
found_entries += ret_entries;
|
found_entries += ret_entries;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -467,9 +472,14 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directo
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!callback_error) {
|
||||||
// num_entries_out is allowed to be specified nullptr, in which case we shouldn't try to set it
|
// num_entries_out is allowed to be specified nullptr, in which case we shouldn't try to set it
|
||||||
if (num_entries_out != nullptr)
|
if (num_entries_out != nullptr)
|
||||||
*num_entries_out = found_entries;
|
*num_entries_out = found_entries;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned ScanDirectoryTree(const std::string &directory, FSTEntry& parent_entry)
|
unsigned ScanDirectoryTree(const std::string &directory, FSTEntry& parent_entry)
|
||||||
|
|
Loading…
Reference in a new issue