summaryrefslogtreecommitdiff
path: root/src/common/file_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/file_util.h')
-rw-r--r--src/common/file_util.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/common/file_util.h b/src/common/file_util.h
index c6a8694ce..32ae2dc57 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -105,11 +105,13 @@ bool CreateEmptyFile(const std::string &filename);
105 * @param num_entries_out to be assigned by the callable with the number of iterated directory entries, never null 105 * @param num_entries_out to be assigned by the callable with the number of iterated directory entries, never null
106 * @param directory the path to the enclosing directory 106 * @param directory the path to the enclosing directory
107 * @param virtual_name the entry name, without any preceding directory info 107 * @param virtual_name the entry name, without any preceding directory info
108 * @param recursion Number of children directory to read before giving up
108 * @return whether handling the entry succeeded 109 * @return whether handling the entry succeeded
109 */ 110 */
110using DirectoryEntryCallable = std::function<bool(unsigned* num_entries_out, 111using DirectoryEntryCallable = std::function<bool(unsigned* num_entries_out,
111 const std::string& directory, 112 const std::string& directory,
112 const std::string& virtual_name)>; 113 const std::string& virtual_name,
114 unsigned int recursion)>;
113 115
114/** 116/**
115 * Scans a directory, calling the callback for each file/directory contained within. 117 * Scans a directory, calling the callback for each file/directory contained within.
@@ -117,20 +119,22 @@ using DirectoryEntryCallable = std::function<bool(unsigned* num_entries_out,
117 * @param num_entries_out assigned by the function with the number of iterated directory entries, can be null 119 * @param num_entries_out assigned by the function with the number of iterated directory entries, can be null
118 * @param directory the directory to scan 120 * @param directory the directory to scan
119 * @param callback The callback which will be called for each entry 121 * @param callback The callback which will be called for each entry
122 * @param recursion Number of children directories to read before giving up
120 * @return whether scanning the directory succeeded 123 * @return whether scanning the directory succeeded
121 */ 124 */
122bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directory, DirectoryEntryCallable callback); 125bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directory, DirectoryEntryCallable callback, unsigned int recursion = 0);
123 126
124/** 127/**
125 * Scans the directory tree, storing the results. 128 * Scans the directory tree, storing the results.
126 * @param directory the parent directory to start scanning from 129 * @param directory the parent directory to start scanning from
127 * @param parent_entry FSTEntry where the filesystem tree results will be stored. 130 * @param parent_entry FSTEntry where the filesystem tree results will be stored.
131 * @param recursion Number of children directories to read before giving up.
128 * @return the total number of files/directories found 132 * @return the total number of files/directories found
129 */ 133 */
130unsigned ScanDirectoryTree(const std::string &directory, FSTEntry& parent_entry); 134unsigned ScanDirectoryTree(const std::string &directory, FSTEntry& parent_entry, unsigned int recursion = 0);
131 135
132// deletes the given directory and anything under it. Returns true on success. 136// deletes the given directory and anything under it. Returns true on success.
133bool DeleteDirRecursively(const std::string &directory); 137bool DeleteDirRecursively(const std::string &directory, unsigned int recursion = 256);
134 138
135// Returns the current directory 139// Returns the current directory
136std::string GetCurrentDir(); 140std::string GetCurrentDir();