File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3432,7 +3432,7 @@ static void CpSyncCopyDir(const FunctionCallbackInfo<Value>& args) {
34323432 bool verbatim_symlinks = args[5 ]->IsTrue ();
34333433 bool preserve_timestamps = args[6 ]->IsTrue ();
34343434
3435- std::function<bool (std::string, std::string)> filter_fn = nullptr ;
3435+ std::optional<std:: function<bool (std::string, std::string)>> filter_fn;
34363436
34373437 if (args[7 ]->IsFunction ()) {
34383438 Local<v8::Function> args_filter_fn = args[7 ].As <v8::Function>();
@@ -3485,12 +3485,9 @@ static void CpSyncCopyDir(const FunctionCallbackInfo<Value>& args) {
34853485 for (auto dir_entry : std::filesystem::directory_iterator (src)) {
34863486 auto dest_file_path = dest / dir_entry.path ().filename ();
34873487
3488- if (filter_fn) {
3489- auto shouldSkip =
3490- !filter_fn (dir_entry.path ().c_str (), dest_file_path.c_str ());
3491- if (shouldSkip) {
3492- continue ;
3493- }
3488+ if (filter_fn.has_value () && !filter_fn.value ()(dir_entry.path ().c_str (),
3489+ dest_file_path.c_str ())) {
3490+ continue ;
34943491 }
34953492
34963493 auto dest_str = PathToString (dest);
You can’t perform that action at this time.
0 commit comments