summaryrefslogtreecommitdiff
path: root/server/continuedev/libs/util/map_path.py
diff options
context:
space:
mode:
Diffstat (limited to 'server/continuedev/libs/util/map_path.py')
-rw-r--r--server/continuedev/libs/util/map_path.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/server/continuedev/libs/util/map_path.py b/server/continuedev/libs/util/map_path.py
new file mode 100644
index 00000000..1dddc2e9
--- /dev/null
+++ b/server/continuedev/libs/util/map_path.py
@@ -0,0 +1,16 @@
+from pathlib import Path
+
+
+def map_path(path: str, orig_root: str, copy_root: str) -> Path:
+ path = Path(path)
+ if path.is_relative_to(orig_root):
+ if path.is_absolute():
+ return Path(copy_root) / path.relative_to(orig_root)
+ else:
+ return path
+ else:
+ if path.is_absolute():
+ return path
+ else:
+ # For this one, you need to know the directory from which the relative path is being used.
+ return Path(orig_root) / path