You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I did run into an issue, though. My expectation was that this pseudo-code should work:
let ref_path = CanonicalPath::new("/foo/bar/").unwrap();let relative_path = Path::new("../baz");let abs_path = ref_path.join(&relative_path).expect("This should succeed!");assert_eq!(CanonicalPath::new("/foo/baz"), abs_path);
In reality, the call to join() fails. This happens because relative_path contains ../ and CanonicalPath::join() just concatenates the two paths and calls CanonicalPathBuf::new(). Since CanonicalPathBuf::new() returns Err if the path is not already canonical, CanonicalPath::join() does as well. If CanonicalPath::join() called CanonicalPathBuf::canonicalize() instead, then this code would work as expected.
For now, I'm using this approach as a workaround:
let abs_path = CanonicalPathBuf::canonicalize(ref_path.as_path().join(&relative_path));
The text was updated successfully, but these errors were encountered:
Nice library! It's quite useful.
I did run into an issue, though. My expectation was that this pseudo-code should work:
In reality, the call to
join()
fails. This happens becauserelative_path
contains../
andCanonicalPath::join()
just concatenates the two paths and callsCanonicalPathBuf::new()
. SinceCanonicalPathBuf::new()
returnsErr
if the path is not already canonical,CanonicalPath::join()
does as well. IfCanonicalPath::join()
calledCanonicalPathBuf::canonicalize()
instead, then this code would work as expected.For now, I'm using this approach as a workaround:
The text was updated successfully, but these errors were encountered: