BloombergLP::bdls::PathUtil::splitFilename

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.

Synopsis

Declared in <bdls_pathutil.h>

static
void
splitFilename(
    std::string_view* head,
    std::string_view* tail,
    std::string_view const& path,
    int rootEnd = -1);