[#BloombergLP-bdls-PathUtil-splitFilename] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdls.adoc[bdls]::xref:BloombergLP/bdls/PathUtil.adoc[PathUtil]::splitFilename :relfileprefix: ../../../ :mrdocs: Split a path into its head and last pathname component. == Synopsis Declared in `<bdls_pathutil.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- static void splitFilename( std::string_view* head, std::string_view* tail, std::string_view const& path, int rootEnd = ‐1); ---- == Description Load the last pathname component from the specified `path` into the specified `tail` and everything leading up to that to the specified `head`. If the optionally specified `rootEnd` offset is non‐negative, it is taken as the position in `path` of the character following the root. The `tail` part never contains a slash; if `path` ends in a slash, `tail` is empty. If there is no slash in `path`, `head` is empty. If `path` is empty, both `head` and `tail` are empty. Trailing slashes are stripped from `head` unless it is the root. ` +‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐+ | PATH | HEAD | TAIL | +#++#===+ | "one" | "" | "one" | +‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐+ | "/one/two/three" | "/one/two" | "three" | +‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐+ | "//one/two///" | "/one/two" | "" | +‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐+ | "c:\one\two" | "c:\one" | "two" | +‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐+ ` See {`Terminology`} for the definition of root. The behavior is undefined unless `head != tail` and `INT_MAX >= path.length()`. Note that `head` or `tail` may point to the `path` object when the method is called. == Parameters [cols="1,4"] |=== | Name| Description | *head* | receives everything in `path` leading up to the last pathname component | *tail* | receives the last pathname component of `path` | *path* | filesystem path to split | *rootEnd* | if non‐negative, position in `path` of the character following the root |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#