MCPcopy Index your code
hub / github.com/nodejs/node / _IsParentOrSame

Function _IsParentOrSame

tools/cpplint.py:7991–8007  ·  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

7989
7990
7991def _IsParentOrSame(parent, child):
7992 """Return true if child is subdirectory of parent.
7993 Assumes both paths are absolute and don't contain symlinks.
7994 """
7995 parent = os.path.normpath(parent)
7996 child = os.path.normpath(child)
7997 if parent == child:
7998 return True
7999
8000 prefix = os.path.commonprefix([parent, child])
8001 if prefix != parent:
8002 return False
8003 # Note: os.path.commonprefix operates on character basis, so
8004 # take extra care of situations like '/foo/ba' and '/foo/bar/baz'
8005 child_suffix = child[len(prefix) :]
8006 child_suffix = child_suffix.lstrip(os.sep)
8007 return child == os.path.join(prefix, child_suffix)
8008
8009
8010def main():

Callers 1

_FilterExcludedFilesFunction · 0.85

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…