Index: gclient_utils.py |
diff --git a/gclient_utils.py b/gclient_utils.py |
index 97d05edd12893eef56e7b4543cbae3db94b30411..af9845784a23d603e30350ec6f4c30ac333edd7c 100644 |
--- a/gclient_utils.py |
+++ b/gclient_utils.py |
@@ -317,3 +317,15 @@ def FindGclientRoot(from_dir): |
return None |
path = next[0] |
return path |
+ |
+def PathDifference(root, subpath): |
+ """Returns the difference subpath minus root.""" |
+ root = os.path.realpath(root) |
+ subpath = os.path.realpath(subpath) |
+ if not subpath.startswith(root): |
+ return None |
+ # If the root does not have a trailing \ or /, we add it so the returned |
+ # path starts immediately after the seperator regardless of whether it is |
+ # provided. |
+ root = os.path.join(root, '') |
+ return subpath[len(root):] |