diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/file_util.cpp | 20 | ||||
| -rw-r--r-- | src/common/file_util.h | 8 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 819ffd6ff..a427372c9 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp | |||
| @@ -386,12 +386,12 @@ bool CreateEmptyFile(const std::string& filename) { | |||
| 386 | return true; | 386 | return true; |
| 387 | } | 387 | } |
| 388 | 388 | ||
| 389 | bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string& directory, | 389 | bool ForeachDirectoryEntry(u64* num_entries_out, const std::string& directory, |
| 390 | DirectoryEntryCallable callback) { | 390 | DirectoryEntryCallable callback) { |
| 391 | LOG_TRACE(Common_Filesystem, "directory {}", directory); | 391 | LOG_TRACE(Common_Filesystem, "directory {}", directory); |
| 392 | 392 | ||
| 393 | // How many files + directories we found | 393 | // How many files + directories we found |
| 394 | unsigned found_entries = 0; | 394 | u64 found_entries = 0; |
| 395 | 395 | ||
| 396 | // Save the status of callback function | 396 | // Save the status of callback function |
| 397 | bool callback_error = false; | 397 | bool callback_error = false; |
| @@ -421,7 +421,7 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string& directo | |||
| 421 | if (virtual_name == "." || virtual_name == "..") | 421 | if (virtual_name == "." || virtual_name == "..") |
| 422 | continue; | 422 | continue; |
| 423 | 423 | ||
| 424 | unsigned ret_entries = 0; | 424 | u64 ret_entries = 0; |
| 425 | if (!callback(&ret_entries, directory, virtual_name)) { | 425 | if (!callback(&ret_entries, directory, virtual_name)) { |
| 426 | callback_error = true; | 426 | callback_error = true; |
| 427 | break; | 427 | break; |
| @@ -445,9 +445,9 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string& directo | |||
| 445 | return true; | 445 | return true; |
| 446 | } | 446 | } |
| 447 | 447 | ||
| 448 | unsigned ScanDirectoryTree(const std::string& directory, FSTEntry& parent_entry, | 448 | u64 ScanDirectoryTree(const std::string& directory, FSTEntry& parent_entry, |
| 449 | unsigned int recursion) { | 449 | unsigned int recursion) { |
| 450 | const auto callback = [recursion, &parent_entry](unsigned* num_entries_out, | 450 | const auto callback = [recursion, &parent_entry](u64* num_entries_out, |
| 451 | const std::string& directory, | 451 | const std::string& directory, |
| 452 | const std::string& virtual_name) -> bool { | 452 | const std::string& virtual_name) -> bool { |
| 453 | FSTEntry entry; | 453 | FSTEntry entry; |
| @@ -459,7 +459,7 @@ unsigned ScanDirectoryTree(const std::string& directory, FSTEntry& parent_entry, | |||
| 459 | // is a directory, lets go inside if we didn't recurse to often | 459 | // is a directory, lets go inside if we didn't recurse to often |
| 460 | if (recursion > 0) { | 460 | if (recursion > 0) { |
| 461 | entry.size = ScanDirectoryTree(entry.physicalName, entry, recursion - 1); | 461 | entry.size = ScanDirectoryTree(entry.physicalName, entry, recursion - 1); |
| 462 | *num_entries_out += (int)entry.size; | 462 | *num_entries_out += entry.size; |
| 463 | } else { | 463 | } else { |
| 464 | entry.size = 0; | 464 | entry.size = 0; |
| 465 | } | 465 | } |
| @@ -470,16 +470,16 @@ unsigned ScanDirectoryTree(const std::string& directory, FSTEntry& parent_entry, | |||
| 470 | (*num_entries_out)++; | 470 | (*num_entries_out)++; |
| 471 | 471 | ||
| 472 | // Push into the tree | 472 | // Push into the tree |
| 473 | parent_entry.children.push_back(entry); | 473 | parent_entry.children.push_back(std::move(entry)); |
| 474 | return true; | 474 | return true; |
| 475 | }; | 475 | }; |
| 476 | 476 | ||
| 477 | unsigned num_entries; | 477 | u64 num_entries; |
| 478 | return ForeachDirectoryEntry(&num_entries, directory, callback) ? num_entries : 0; | 478 | return ForeachDirectoryEntry(&num_entries, directory, callback) ? num_entries : 0; |
| 479 | } | 479 | } |
| 480 | 480 | ||
| 481 | bool DeleteDirRecursively(const std::string& directory, unsigned int recursion) { | 481 | bool DeleteDirRecursively(const std::string& directory, unsigned int recursion) { |
| 482 | const auto callback = [recursion](unsigned* num_entries_out, const std::string& directory, | 482 | const auto callback = [recursion](u64* num_entries_out, const std::string& directory, |
| 483 | const std::string& virtual_name) -> bool { | 483 | const std::string& virtual_name) -> bool { |
| 484 | std::string new_path = directory + DIR_SEP_CHR + virtual_name; | 484 | std::string new_path = directory + DIR_SEP_CHR + virtual_name; |
| 485 | 485 | ||
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 | */ |
| 86 | using DirectoryEntryCallable = std::function<bool( | 86 | using 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 | */ |
| 98 | bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string& directory, | 98 | bool 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 | */ |
| 108 | unsigned ScanDirectoryTree(const std::string& directory, FSTEntry& parent_entry, | 108 | u64 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. |
| 112 | bool DeleteDirRecursively(const std::string& directory, unsigned int recursion = 256); | 112 | bool DeleteDirRecursively(const std::string& directory, unsigned int recursion = 256); |