[#BloombergLP-bdls-FilesystemUtil-visitPaths-042]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdls.adoc[bdls]::xref:BloombergLP/bdls/FilesystemUtil.adoc[FilesystemUtil]::visitPaths
:relfileprefix: ../../../
:mrdocs:

Call `visitor` for each filesystem path matching the specified `pattern`&period;

== Synopsis

Declared in `&lt;bdls&lowbar;filesystemutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
visitPaths(
    char const* pattern,
    xref:bsl/function-0a.adoc[bsl::function&lt;void(char const*)&gt;] const& visitor);
----

== Description

Call the specified `visitor` function object for each path in the filesystem matching the specified `pattern`&period; Return the number of paths visited on success, and a negative value otherwise&period; Note that if `visitor` deletes files or directories during the search, `visitor` may subsequently be called with paths which have already been deleted, so must be prepared for this event&period; Also note that there is no guarantee as to the order in which paths will be visited&period; See `findMatchingPaths` for a discussion of how `pattern` is interpreted&period; Also note that `&period;` and `&period;&period;` are never matched by wild cards&period; The parameterized `STRING&lowbar;TYPE` must be one of `bsl&colon;&colon;string`, `std&colon;&colon;string`, `std&colon;&colon;pmr&colon;&colon;string` (if supported), `bsl&colon;&colon;string&lowbar;view`, or `bslstl&colon;&colon;StringRef`&period;

IBM&hyphen;SPECIFIC WARNING&colon; This function is not thread&hyphen;safe&period; The AIX implementation of the system `glob` function can temporarily change the working directory of the entire program, causing attempts in other threads to open files with relative path names to fail&period;

== Return Value

the number of paths visited on success, and a negative value otherwise

== Parameters

[cols="1,4"]
|===
| Name| Description
| *pattern*
| glob&hyphen;style pattern of paths to visit
| *visitor*
| functor invoked with each matching path
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
