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

This struct contains utility methods for platform&hyphen;independent manipulation of filesystem paths&period; No method of this struct provides any filesystem operations or accesses the filesystem as part of its implementation&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
struct PathUtil;
----

== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdls/PathUtil/appendIfValid-0a.adoc[`appendIfValid`] 
| Append the specified `filename` to the end of the specified `path` if `filename` represents a relative path&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; Note that any filesystem separator characters at the end of `filename` or `path` will be discarded&period; See  for the definition of separator&period;
| xref:BloombergLP/bdls/PathUtil/appendRaw-084.adoc[`appendRaw`] 
| Append the specified `filename` up to the optionally specified `length` to the end of the specified `path`&period; If `length` is negative, append the entire string&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; The behavior is undefined if `filename` represents an absolute path or if either `filename` or `path` ends with the filesystem separator character&period; The behavior is also undefined if `filename` points to any part of `path` (i&period;e&period;, `filename` may not be an alias for `path`)&period; See &lsqb;&rsqb;and Performance)&period;
| xref:BloombergLP/bdls/PathUtil/getBasename-04.adoc[`getBasename`] 
| Load into the specified `leaf` the value of the rightmost name in the specified `path` that follows the root&semi; that is, the leaf element&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 nonzero if `path` does not have a leaf&period; Note that `getBasename` is a synonym for `getLeaf`&period; See &lsqb;&rsqb;and Performance)&period; See also  for the definition of leaf and root&period;
| xref:BloombergLP/bdls/PathUtil/getDirname-0b.adoc[`getDirname`] 
| 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;
| xref:BloombergLP/bdls/PathUtil/getExtension-0b.adoc[`getExtension`] 
| Load into the specified `extension` the extension of `path`&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 if the path has an extension, and a non&hyphen;zero value otherwise&period; See &lsqb;&rsqb;and Performance)&period; See also  for the definition of leaf and root&period;
| xref:BloombergLP/bdls/PathUtil/getLeaf-0d.adoc[`getLeaf`] 
| Load into the specified `leaf` the value of the rightmost name in the specified `path` that follows the root&semi; that is, the leaf element&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 nonzero if `path` does not have a leaf&period; Note that `getBasename` is a synonym for `getLeaf`&period; See &lsqb;&rsqb;and Performance)&period; See also  for the definition of leaf and root&period;
| xref:BloombergLP/bdls/PathUtil/getRoot-04.adoc[`getRoot`] 
| Load into the specified &apos;root&apos; the value of the root part of the specified &apos;path&apos;&period; If the optionally specified &apos;rootEnd&apos; offset is non&hyphen;negative, it is taken as the position in &apos;path&apos; 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 &apos;path&apos; is relative&period; Note that the meaning of the root part is platform&hyphen;dependent&period; See &lsqb;&rsqb;and Performance)&period; See also  for the definition of root&period;
| xref:BloombergLP/bdls/PathUtil/getRootEnd.adoc[`getRootEnd`] 
| Return the 0&hyphen;based position in the specified `path` of the character following the root&period; Note that a return value of 0 indicates a relative path&period; See &lsqb;&rsqb;and Performance)&period; See also  for the definition of root&period;
| xref:BloombergLP/bdls/PathUtil/hasLeaf.adoc[`hasLeaf`] 
| Return `true` if the specified `path` has a filename following the root, and `false` otherwise&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; See &lsqb;&rsqb;and Performance)&period; See also  for the definition of root&period;
| xref:BloombergLP/bdls/PathUtil/isAbsolute.adoc[`isAbsolute`] 
| Return `true` if the specified `path` is absolute (has a root), and `false` otherwise&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; See &lsqb;&rsqb;and Performance)&period; See also  for the definition of root&period;
| xref:BloombergLP/bdls/PathUtil/isRelative.adoc[`isRelative`] 
| Return `true` if the specified `path` is relative (lacks a root), and `false` otherwise&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; See &lsqb;&rsqb;and Performance)&period; See also  for the definition of root&period;
| xref:BloombergLP/bdls/PathUtil/popLeaf-0f.adoc[`popLeaf`] 
| Remove from the specified `path` the rightmost filename following the root&semi; that is, remove the leaf element&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 nonzero value otherwise&semi; in particular, return a nonzero value if `path` does not have a leaf&period; See &lsqb;&rsqb;and Performance)&period; See also  for the definition of leaf and root&period;
| xref:BloombergLP/bdls/PathUtil/splitFilename.adoc[`splitFilename`] 
| Load the last pathname component from the specified `path` into the specified `tail` and everything leading up to that to the specified `head`&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; The `tail` part never contains a slash&semi; if `path` ends in a slash, `tail` is empty&period; If there is no slash in `path`, `head` is empty&period; If `path` is empty, both `head` and `tail` are empty&period; Trailing slashes are stripped from `head` unless it is the root&period; &grave; &plus;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&plus;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&plus;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&plus; &verbar; PATH &verbar; HEAD &verbar; TAIL &verbar; &plus;#&plus;&plus;#&equals;&equals;&equals;&plus; &verbar; &quot;one&quot; &verbar; &quot;&quot; &verbar; &quot;one&quot; &verbar; &plus;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&plus;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&plus;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&plus; &verbar; &quot;&sol;one&sol;two&sol;three&quot; &verbar; &quot;&sol;one&sol;two&quot; &verbar; &quot;three&quot; &verbar; &plus;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&plus;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&plus;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&plus; &verbar; &quot;&sol;&sol;one&sol;two&sol;&sol;&sol;&quot; &verbar; &quot;&sol;one&sol;two&quot; &verbar; &quot;&quot; &verbar; &plus;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&plus;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&plus;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&plus; &verbar; &quot;c&colon;&bsol;one&bsol;two&quot; &verbar; &quot;c&colon;&bsol;one&quot; &verbar; &quot;two&quot; &verbar; &plus;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&plus;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&plus;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&hyphen;&plus; &grave; See &lcub;`Terminology`&rcub; for the definition of root&period; The behavior is undefined unless `head !&equals; tail` and `INT&lowbar;MAX &gt;&equals; path&period;length()`&period; Note that `head` or `tail` may point to the `path` object when the method is called&period;
|===


== Static Data Members

[cols="1"]
|===
| Name
| xref:BloombergLP/bdls/PathUtil/k_SEPARATOR.adoc[`k&lowbar;SEPARATOR`] 
|===



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