summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/file_util.cpp18
-rw-r--r--src/common/file_util.h8
2 files changed, 13 insertions, 13 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 543adbffb..47ac8368e 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -396,12 +396,12 @@ bool CreateEmptyFile(const std::string& filename) {
396 return true; 396 return true;
397} 397}
398 398
399bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string& directory, 399bool ForeachDirectoryEntry(u64* num_entries_out, const std::string& directory,
400 DirectoryEntryCallable callback) { 400 DirectoryEntryCallable callback) {
401 LOG_TRACE(Common_Filesystem, "directory {}", directory); 401 LOG_TRACE(Common_Filesystem, "directory {}", directory);
402 402
403 // How many files + directories we found 403 // How many files + directories we found
404 unsigned found_entries = 0; 404 u64 found_entries = 0;
405 405
406 // Save the status of callback function 406 // Save the status of callback function
407 bool callback_error = false; 407 bool callback_error = false;
@@ -431,7 +431,7 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string& directo
431 if (virtual_name == "." || virtual_name == "..") 431 if (virtual_name == "." || virtual_name == "..")
432 continue; 432 continue;
433 433
434 unsigned ret_entries = 0; 434 u64 ret_entries = 0;
435 if (!callback(&ret_entries, directory, virtual_name)) { 435 if (!callback(&ret_entries, directory, virtual_name)) {
436 callback_error = true; 436 callback_error = true;
437 break; 437 break;
@@ -455,9 +455,9 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string& directo
455 return true; 455 return true;
456} 456}
457 457
458unsigned ScanDirectoryTree(const std::string& directory, FSTEntry& parent_entry, 458u64 ScanDirectoryTree(const std::string& directory, FSTEntry& parent_entry,
459 unsigned int recursion) { 459 unsigned int recursion) {
460 const auto callback = [recursion, &parent_entry](unsigned* num_entries_out, 460 const auto callback = [recursion, &parent_entry](u64* num_entries_out,
461 const std::string& directory, 461 const std::string& directory,
462 const std::string& virtual_name) -> bool { 462 const std::string& virtual_name) -> bool {
463 FSTEntry entry; 463 FSTEntry entry;
@@ -469,7 +469,7 @@ unsigned ScanDirectoryTree(const std::string& directory, FSTEntry& parent_entry,
469 // is a directory, lets go inside if we didn't recurse to often 469 // is a directory, lets go inside if we didn't recurse to often
470 if (recursion > 0) { 470 if (recursion > 0) {
471 entry.size = ScanDirectoryTree(entry.physicalName, entry, recursion - 1); 471 entry.size = ScanDirectoryTree(entry.physicalName, entry, recursion - 1);
472 *num_entries_out += (int)entry.size; 472 *num_entries_out += entry.size;
473 } else { 473 } else {
474 entry.size = 0; 474 entry.size = 0;
475 } 475 }
@@ -484,12 +484,12 @@ unsigned ScanDirectoryTree(const std::string& directory, FSTEntry& parent_entry,
484 return true; 484 return true;
485 }; 485 };
486 486
487 unsigned num_entries; 487 u64 num_entries;
488 return ForeachDirectoryEntry(&num_entries, directory, callback) ? num_entries : 0; 488 return ForeachDirectoryEntry(&num_entries, directory, callback) ? num_entries : 0;
489} 489}
490 490
491bool DeleteDirRecursively(const std::string& directory, unsigned int recursion) { 491bool DeleteDirRecursively(const std::string& directory, unsigned int recursion) {
492 const auto callback = [recursion](unsigned* num_entries_out, const std::string& directory, 492 const auto callback = [recursion](u64* num_entries_out, const std::string& directory,
493 const std::string& virtual_name) -> bool { 493 const std::string& virtual_name) -> bool {
494 std::string new_path = directory + DIR_SEP_CHR + virtual_name; 494 std::string new_path = directory + DIR_SEP_CHR + virtual_name;
495 495
diff --git a/src/common/file_util.h b/src/common/file_util.h
index ff01bf0ff..090907c03 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -84,7 +84,7 @@ bool CreateEmptyFile(const std::string& filename);
84 * @return whether handling the entry succeeded 84 * @return whether handling the entry succeeded
85 */ 85 */
86using DirectoryEntryCallable = std::function<bool( 86using DirectoryEntryCallable = std::function<bool(
87 unsigned* num_entries_out, const std::string& directory, const std::string& virtual_name)>; 87 u64* num_entries_out, const std::string& directory, const std::string& virtual_name)>;
88 88
89/** 89/**
90 * Scans a directory, calling the callback for each file/directory contained within. 90 * Scans a directory, calling the callback for each file/directory contained within.
@@ -95,7 +95,7 @@ using DirectoryEntryCallable = std::function<bool(
95 * @param callback The callback which will be called for each entry 95 * @param callback The callback which will be called for each entry
96 * @return whether scanning the directory succeeded 96 * @return whether scanning the directory succeeded
97 */ 97 */
98bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string& directory, 98bool ForeachDirectoryEntry(u64* num_entries_out, const std::string& directory,
99 DirectoryEntryCallable callback); 99 DirectoryEntryCallable callback);
100 100
101/** 101/**
@@ -105,8 +105,8 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string& directo
105 * @param recursion Number of children directories to read before giving up. 105 * @param recursion Number of children directories to read before giving up.
106 * @return the total number of files/directories found 106 * @return the total number of files/directories found
107 */ 107 */
108unsigned ScanDirectoryTree(const std::string& directory, FSTEntry& parent_entry, 108u64 ScanDirectoryTree(const std::string& directory, FSTEntry& parent_entry,
109 unsigned int recursion = 0); 109 unsigned int recursion = 0);
110 110
111// deletes the given directory and anything under it. Returns true on success. 111// deletes the given directory and anything under it. Returns true on success.
112bool DeleteDirRecursively(const std::string& directory, unsigned int recursion = 256); 112bool DeleteDirRecursively(const std::string& directory, unsigned int recursion = 256);