[#BloombergLP-bdls-PathUtil-getDirname-0b]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdls.adoc[bdls]::xref:BloombergLP/bdls/PathUtil.adoc[PathUtil]::getDirname
:relfileprefix: ../../../
:mrdocs:

Load into the specified `dirname` the value of the directory part of the specified `path`, that is, the root if it exists and all the filenames except the last one (the leaf)&period; If the optionally specified `rootEnd` offset is non&hyphen;negative, it is taken as the position in `path` of the character following the root&period; Return 0 on success, and a non&hyphen;zero value otherwise&semi; in particular, return a nonzero value if `path` does not have a leaf&period; Note that in the case of a relative path with a single filename, the function will succeed and `dirname` will be the empty string&period; See &lsqb;&rsqb;and Performance)&period; See also  for the definition of directories and root&period;

== Synopses

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

Load into the specified `dirname` the value of the directory part of the specified `path`, that is, the root if it exists and all the filenames except the last one (the leaf)&period; If the optionally specified `rootEnd` offset is non&hyphen;negative, it is taken as the position in `path` of the character following the root&period; Return 0 on success, and a non&hyphen;zero value otherwise&semi; in particular, return a nonzero value if `path` does not have a leaf&period; Note that in the case of a relative path with a single filename, the function will succeed and `dirname` will be the empty string&period; See &lsqb;&rsqb;and Performance)&period; See also  for the definition of directories and root&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
xref:BloombergLP/bdls/PathUtil/getDirname-0e.adoc[getDirname](
    xref:bsl/string.adoc[bsl::string]* dirname,
    std::string&lowbar;view const& path,
    int rootEnd = &hyphen;1);
----

[.small]#xref:BloombergLP/bdls/PathUtil/getDirname-0e.adoc[_» more&period;&period;&period;_]#


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
xref:BloombergLP/bdls/PathUtil/getDirname-0f.adoc[getDirname](
    std::pmr::string* dirname,
    std::string&lowbar;view const& path,
    int rootEnd = &hyphen;1);
----

[.small]#xref:BloombergLP/bdls/PathUtil/getDirname-0f.adoc[_» more&period;&period;&period;_]#


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
xref:BloombergLP/bdls/PathUtil/getDirname-01.adoc[getDirname](
    std::string* dirname,
    std::string&lowbar;view const& path,
    int rootEnd = &hyphen;1);
----

[.small]#xref:BloombergLP/bdls/PathUtil/getDirname-01.adoc[_» more&period;&period;&period;_]#


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