on master help sign in
Add a comment to `canonicalize_path`
bcb1afeWojciech Kępka
helix-view/src/document.rs+4
@@ -104,6 +104,10 @@ pub fn normalize_path(path: &Path) -> PathBuf {
104 ret
104 ret
105}
105}
106
106
107+// Returns the canonical, absolute form of a path with all intermediate components normalized.
108+//
109+// This function is used instead of `std::fs::canonicalize` because we don't want to verify
110+// here if the path exists, just normalize it's components.
107pub fn canonicalize_path(path: &Path) -> std::io::Result<PathBuf> {
111pub fn canonicalize_path(path: &Path) -> std::io::Result<PathBuf> {
108 std::env::current_dir().map(|current_dir| normalize_path(&current_dir.join(path)))
112 std::env::current_dir().map(|current_dir| normalize_path(&current_dir.join(path)))
109}
113}