MCPcopy Index your code
hub / github.com/cpplint/cpplint / _IsParentOrSame

Function _IsParentOrSame

cpplint.py:7840–7856  ·  view source on GitHub ↗

Return true if child is subdirectory of parent. Assumes both paths are absolute and don't contain symlinks.

(parent, child)

Source from the content-addressed store, hash-verified

7838
7839
7840def _IsParentOrSame(parent, child):
7841 """Return true if child is subdirectory of parent.
7842 Assumes both paths are absolute and don't contain symlinks.
7843 """
7844 parent = os.path.normpath(parent)
7845 child = os.path.normpath(child)
7846 if parent == child:
7847 return True
7848
7849 prefix = os.path.commonprefix([parent, child])
7850 if prefix != parent:
7851 return False
7852 # Note: os.path.commonprefix operates on character basis, so
7853 # take extra care of situations like '/foo/ba' and '/foo/bar/baz'
7854 child_suffix = child[len(prefix) :]
7855 child_suffix = child_suffix.lstrip(os.sep)
7856 return child == os.path.join(prefix, child_suffix)
7857
7858
7859def main():

Callers 1

_FilterExcludedFilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected