diff options
author | archshift <gh@archshift.com> | 2015-09-01 03:29:23 +0200 |
---|---|---|
committer | archshift <gh@archshift.com> | 2015-10-01 06:04:47 +0200 |
commit | 7134a17fc6cb7ab8ae46dae04f005bb72e0af88e (patch) | |
tree | a7276d2efdbeae8ea1fd84e81eca3bfa6a34e7df /src/common/file_util.h | |
parent | Expose loader helper functions for identifying files. (diff) | |
download | yuzu-7134a17fc6cb7ab8ae46dae04f005bb72e0af88e.tar yuzu-7134a17fc6cb7ab8ae46dae04f005bb72e0af88e.tar.gz yuzu-7134a17fc6cb7ab8ae46dae04f005bb72e0af88e.tar.bz2 yuzu-7134a17fc6cb7ab8ae46dae04f005bb72e0af88e.tar.lz yuzu-7134a17fc6cb7ab8ae46dae04f005bb72e0af88e.tar.xz yuzu-7134a17fc6cb7ab8ae46dae04f005bb72e0af88e.tar.zst yuzu-7134a17fc6cb7ab8ae46dae04f005bb72e0af88e.zip |
Diffstat (limited to 'src/common/file_util.h')
-rw-r--r-- | src/common/file_util.h | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/common/file_util.h b/src/common/file_util.h index e71a9b2fa..3d617f573 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -6,6 +6,7 @@ #include <array> #include <fstream> +#include <functional> #include <cstddef> #include <cstdio> #include <string> @@ -96,9 +97,28 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename); // creates an empty file filename, returns true on success bool CreateEmptyFile(const std::string &filename); -// Scans the directory tree gets, starting from _Directory and adds the -// results into parentEntry. Returns the number of files+directories found -u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry); +/** + * Scans the directory tree, calling the callback for each file/directory found. + * The callback must return the number of files and directories which the provided path contains. + * If the callback's return value is -1, the callback loop is broken immediately. + * If the callback's return value is otherwise negative, the callback loop is broken immediately + * and the callback's return value is returned from this function (to allow for error handling). + * @param directory the parent directory to start scanning from + * @param callback The callback which will be called for each file/directory. It is called + * with the arguments (const std::string& directory, const std::string& virtual_name). + * The `directory `parameter is the path to the directory which contains the file/directory. + * The `virtual_name` parameter is the incomplete file path, without any directory info. + * @return the total number of files/directories found + */ +int ScanDirectoryTreeAndCallback(const std::string &directory, std::function<int(const std::string&, const std::string&)> callback); + +/** + * Scans the directory tree, storing the results. + * @param directory the parent directory to start scanning from + * @param parent_entry FSTEntry where the filesystem tree results will be stored. + * @return the total number of files/directories found + */ +int ScanDirectoryTree(const std::string &directory, FSTEntry& parent_entry); // deletes the given directory and anything under it. Returns true on success. bool DeleteDirRecursively(const std::string &directory); |