Index: tools/telemetry/telemetry/util/path.py |
diff --git a/tools/telemetry/telemetry/util/path.py b/tools/telemetry/telemetry/util/path.py |
index 7feb861bdfba2c627cae5c062d998c5da32f7d29..c9018139424f3ab3f3eb03f63c3d3ba3d04811db 100644 |
--- a/tools/telemetry/telemetry/util/path.py |
+++ b/tools/telemetry/telemetry/util/path.py |
@@ -41,3 +41,15 @@ def FindInstalledWindowsApplication(application_path): |
return path |
return None |
+ |
+ |
+def IsSubpath(subpath, superpath): |
+ """Returns True iff subpath is or is in superpath.""" |
+ subpath = os.path.realpath(subpath) |
+ superpath = os.path.realpath(superpath) |
+ |
+ while len(subpath) >= len(superpath): |
+ if subpath == superpath: |
+ return True |
+ subpath = os.path.split(subpath)[0] |
+ return False |