[#mrdocs-forEachFile-03]
= xref:mrdocs.adoc[mrdocs]::forEachFile
:relfileprefix: ../
:mrdocs:

Call a function for each file in a directory&period;

== Synopsis

Declared in `&lt;mrdocs&sol;Support&sol;Path&period;hpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:mrdocs/Expected-0a.adoc[Expected&lt;void&gt;]
forEachFile(
    std::string&lowbar;view dirPath,
    bool recursive,
    xref:mrdocs/AnyFileVisitor.adoc[AnyFileVisitor]& visitor);
----

== Description

This will iterate all the regular files in a directory and invoke the visitor with the path&period;

== Return Value

An error if any occurred&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *dirPath*
| The path to the directory&period;
| *recursive*
| If true, files in subdirectories are also visited, recursively&period;
| *visitor*
| The visitor to invoke for each file&period;
|===


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