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..fce896e1666cc87fe18f0465dcf39caed2b18092 100644 |
--- a/tools/telemetry/telemetry/util/path.py |
+++ b/tools/telemetry/telemetry/util/path.py |
@@ -41,3 +41,17 @@ def FindInstalledWindowsApplication(application_path): |
return path |
return None |
+ |
+ |
+def InDirectory(subdirectory, directory): |
+ """Returns True iff subdirectory is or is in directory. |
+ |
+ A little bit of a misnomer, since it works even if they're files.""" |
eakuefner
2015/03/27 17:55:06
Do we actually need this? Why not just get the pat
dtu
2015/03/27 19:17:15
This is surprisingly tricky, and people get it wro
|
+ subdirectory = os.path.realpath(subdirectory) |
+ directory = os.path.realpath(directory) |
+ |
+ while len(subdirectory) >= len(directory): |
+ if subdirectory == directory: |
+ return True |
+ subdirectory = os.path.split(subdirectory)[0] |
+ return False |