summaryrefslogtreecommitdiff
path: root/src/common/file_util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/file_util.cpp')
-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
427 // How many files + directories we found 427 // How many files + directories we found
428 unsigned found_entries = 0; 428 unsigned found_entries = 0;
429 429
430 // Save the status of callback function
431 bool callback_error = false;
432
430#ifdef _WIN32 433#ifdef _WIN32
431 // Find the first file in the directory. 434 // Find the first file in the directory.
432 WIN32_FIND_DATA ffd; 435 WIN32_FIND_DATA ffd;
@@ -455,8 +458,10 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directo
455 continue; 458 continue;
456 459
457 unsigned ret_entries; 460 unsigned ret_entries;
458 if (!callback(&ret_entries, directory, virtual_name)) 461 if (!callback(&ret_entries, directory, virtual_name)) {
462 callback_error = true;
459 break; 463 break;
464 }
460 found_entries += ret_entries; 465 found_entries += ret_entries;
461 466
462#ifdef _WIN32 467#ifdef _WIN32
@@ -467,9 +472,14 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directo
467 closedir(dirp); 472 closedir(dirp);
468#endif 473#endif
469 474
470 // num_entries_out is allowed to be specified nullptr, in which case we shouldn't try to set it 475 if (!callback_error) {
471 if (num_entries_out != nullptr) 476 // num_entries_out is allowed to be specified nullptr, in which case we shouldn't try to set it
472 *num_entries_out = found_entries; 477 if (num_entries_out != nullptr)
478 *num_entries_out = found_entries;
479 return true;
480 } else {
481 return false;
482 }
473} 483}
474 484
475unsigned ScanDirectoryTree(const std::string &directory, FSTEntry& parent_entry) 485unsigned ScanDirectoryTree(const std::string &directory, FSTEntry& parent_entry)