Checks if the given path starts with the specified prefix.

Synopsis

Declared in <mrdocs/Support/Path.hpp>

bool
startsWith(
    std::string_view pathName,
    std::string_view prefix);

Description

This function compares the beginning of the pathName with the prefix. It returns true if pathName starts with prefix. The comparison is case‐sensitive.

Unlike a direct string comparison, this function also accepts differences in the slashes used to separate paths. Therefore, it returns true even when the slashes used in pathName and prefix are not the same. The function accepts both forward slashes ("/") and backslashes ("").

Return Value

A boolean value. Returns true if pathName starts with prefix, false otherwise.

Parameters

Name

Description

pathName

A string view representing the path to be checked.

prefix

A string view representing the prefix to be checked against the path.

Created with MrDocs