mrdocs::files::isSubpathOf

Checks whether the given path lies within the specified prefix.

Synopsis

Declared in <mrdocs/Support/Path.hpp>

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

Description

It returns true if pathName is prefix or lies underneath it. The comparison walks whole path segments rather than characters, so /abc contains /abc/def but not /abcdef. 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 ("").

It does not resolve symbolic links; use isResolvedSubpathOf when symlink equivalence matters.

Return Value

A boolean value. Returns true if pathName lies within 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