diff options
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r-- | mesonbuild/mesonlib.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 6c1e466..b901ec9 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -1533,6 +1533,16 @@ def relpath(path: str, start: str) -> str: except (TypeError, ValueError): return path +def path_is_in_root(path: Path, root: Path, resolve: bool = False) -> bool: + # Check wheter a path is within the root directory root + try: + if resolve: + path.resolve().relative_to(root.resolve()) + else: + path.relative_to(root) + except ValueError: + return False + return True class LibType(Enum): |