Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ pub fn exists(junction: &Path) -> io::Result<bool> {
}

pub fn get_target(junction: &Path) -> io::Result<PathBuf> {
// MSRV(1.63): use Path::try_exists instead
if !junction.exists() {
return Err(io::Error::new(io::ErrorKind::NotFound, "`junction` does not exist"));
}
let file = helpers::open_reparse_point(junction, false)?;
let mut data = BytesAsReparseDataBuffer::new();
helpers::get_reparse_data_point(file.as_raw_handle(), data.as_mut_ptr())?;
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ pub fn exists<P: AsRef<Path>>(junction: P) -> io::Result<bool> {

/// Gets the target of the specified junction point.
///
/// This returns the target path of the junction point, even if the target does not exist.
///
/// N.B. Only works on NTFS.
///
/// # Example
Expand Down
14 changes: 14 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,20 @@ fn get_target_user_dirs() {
}
}

#[test]
fn get_target_target_no_exist() {
let tmpdir = create_tempdir();

let target = tmpdir.path().join("target");
let junction = tmpdir.path().join("junction");

super::create(&target, &junction).unwrap();
match super::get_target(&junction) {
Ok(t) => assert_eq!(t, target),
other => panic!("get_target should succeed when target does not exist: {:?}", other),
}
}

#[test]
fn create_with_verbatim_prefix_paths() {
// Regression test for https://github.com/tesuji/junction/issues/30
Expand Down
Loading