[Lldb-commits] [PATCH] D47535: [FileSpec] Add support for lambdas to EnumerateDirectory. NFC
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed May 30 07:44:33 PDT 2018
JDevlieghere created this revision.
JDevlieghere added reviewers: clayborg, labath.
Herald added a subscriber: llvm-commits.
Support both lambda's and function pointers as arguments to EnumerateDirectory.
Repository:
rL LLVM
https://reviews.llvm.org/D47535
Files:
include/lldb/Utility/FileSpec.h
source/Utility/FileSpec.cpp
Index: source/Utility/FileSpec.cpp
===================================================================
--- source/Utility/FileSpec.cpp
+++ source/Utility/FileSpec.cpp
@@ -640,6 +640,18 @@
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton) {
+ auto callbackLambda = [=](llvm::sys::fs::file_type file_type,
+ const FileSpec &spec) -> EnumerateDirectoryResult {
+ return callback(callback_baton, file_type, spec);
+ };
+ return EnumerateDirectory(dir_path, find_directories, find_files, find_other,
+ callbackLambda);
+}
+
+void FileSpec::EnumerateDirectory(llvm::StringRef dir_path,
+ bool find_directories, bool find_files,
+ bool find_other,
+ EnumerateDirectoryCallbackFnType callback) {
namespace fs = llvm::sys::fs;
std::error_code EC;
fs::recursive_directory_iterator Iter(dir_path, EC);
@@ -657,7 +669,7 @@
continue;
FileSpec Spec(Item.path(), false);
- auto Result = callback(callback_baton, Status->type(), Spec);
+ auto Result = callback(Status->type(), Spec);
if (Result == eEnumerateDirectoryResultQuit)
return;
if (Result == eEnumerateDirectoryResultNext) {
Index: include/lldb/Utility/FileSpec.h
===================================================================
--- include/lldb/Utility/FileSpec.h
+++ include/lldb/Utility/FileSpec.h
@@ -562,7 +562,12 @@
typedef std::function<EnumerateDirectoryResult(
llvm::sys::fs::file_type file_type, const FileSpec &spec)>
- DirectoryCallback;
+ EnumerateDirectoryCallbackFnType;
+
+ static void EnumerateDirectory(llvm::StringRef dir_path,
+ bool find_directories, bool find_files,
+ bool find_other,
+ EnumerateDirectoryCallbackFnType callback);
protected:
//------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47535.149117.patch
Type: text/x-patch
Size: 2145 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180530/db5faa6b/attachment.bin>
More information about the lldb-commits
mailing list