Sha256: cfd2ad4ac6f1588d43d0cf8b1f92f736515299a0738824095b86432ab81027e2

Contents?: true

Size: 959 Bytes

Versions: 36

Compression:

Stored size: 959 Bytes

Contents

use super::open_parent;
use crate::fs::{read_link_unchecked, MaybeOwnedFile};
use std::path::{Path, PathBuf};
use std::{fs, io};

/// Implement `read_link` by `open`ing up the parent component of the path and
/// then calling `read_link_unchecked` on the last component.
///
/// This technique doesn't work in all cases on Windows. In particular, a
/// directory symlink such as `C:\Documents and Settings` may not grant any
/// access other than what is needed to resolve the symlink, so `open_parent`'s
/// technique of returning a relative path of `.` from that point doesn't work,
/// because opening `.` within such a directory is denied. Consequently, we use
/// a different implementation on Windows.
pub(crate) fn read_link(start: &fs::File, path: &Path) -> io::Result<PathBuf> {
    let start = MaybeOwnedFile::borrowed(start);

    let (dir, basename) = open_parent(start, path)?;

    read_link_unchecked(&dir, basename.as_ref(), PathBuf::new())
}

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
wasmtime-27.0.0 ./ext/cargo-vendor/cap-primitives-3.4.1/src/fs/via_parent/read_link.rs
wasmtime-26.0.0 ./ext/cargo-vendor/cap-primitives-3.3.0/src/fs/via_parent/read_link.rs
wasmtime-25.0.2 ./ext/cargo-vendor/cap-primitives-3.2.0/src/fs/via_parent/read_link.rs
wasmtime-25.0.1 ./ext/cargo-vendor/cap-primitives-3.2.0/src/fs/via_parent/read_link.rs
wasmtime-25.0.0 ./ext/cargo-vendor/cap-primitives-3.2.0/src/fs/via_parent/read_link.rs
wasmtime-24.0.0 ./ext/cargo-vendor/cap-primitives-3.2.0/src/fs/via_parent/read_link.rs
wasmtime-23.0.2 ./ext/cargo-vendor/cap-primitives-3.1.0/src/fs/via_parent/read_link.rs
wasmtime-22.0.0 ./ext/cargo-vendor/cap-primitives-3.1.0/src/fs/via_parent/read_link.rs
wasmtime-21.0.1 ./ext/cargo-vendor/cap-primitives-3.1.0/src/fs/via_parent/read_link.rs
wasmtime-20.0.2 ./ext/cargo-vendor/cap-primitives-3.1.0/src/fs/via_parent/read_link.rs
wasmtime-20.0.0 ./ext/cargo-vendor/cap-primitives-3.0.0/src/fs/via_parent/read_link.rs
wasmtime-18.0.3 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/via_parent/read_link.rs
wasmtime-17.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/via_parent/read_link.rs
wasmtime-17.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/via_parent/read_link.rs
wasmtime-16.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/via_parent/read_link.rs
wasmtime-15.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/via_parent/read_link.rs
wasmtime-15.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/via_parent/read_link.rs
wasmtime-14.0.4 ./ext/cargo-vendor/cap-primitives-2.0.0/src/fs/via_parent/read_link.rs
wasmtime-14.0.3 ./ext/cargo-vendor/cap-primitives-2.0.0/src/fs/via_parent/read_link.rs
wasmtime-14.0.1 ./ext/cargo-vendor/cap-primitives-2.0.0/src/fs/via_parent/read_link.rs