Sha256: eb4901c756e860774c5d676213befe72521f91f0a4a61e600d7b4dbe91855747

Contents?: true

Size: 902 Bytes

Versions: 25

Compression:

Stored size: 902 Bytes

Contents

use crate::fs::{open, FollowSymlinks, OpenOptions};
use std::os::windows::fs::OpenOptionsExt;
use std::path::{Path, PathBuf};
use std::{fs, io};
use windows_sys::Win32::Storage::FileSystem::{
    FILE_FLAG_BACKUP_SEMANTICS, FILE_FLAG_OPEN_REPARSE_POINT,
};

/// *Unsandboxed* function similar to `read_link`, but which does not perform
/// sandboxing.
pub(crate) fn read_link_impl(start: &fs::File, path: &Path) -> io::Result<PathBuf> {
    // Open the link with no access mode, instead of generic read.
    // By default FILE_LIST_DIRECTORY is denied for the junction "C:\Documents and
    // Settings", so this is needed for a common case.
    let mut opts = OpenOptions::new();
    opts.access_mode(0);
    opts.custom_flags(FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS);
    opts.follow(FollowSymlinks::No);
    let file = open(start, path, &opts)?;
    winx::file::read_link(&file)
}

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
wasmtime-18.0.3 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/read_link_impl.rs
wasmtime-17.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/read_link_impl.rs
wasmtime-17.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/read_link_impl.rs
wasmtime-16.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/read_link_impl.rs
wasmtime-15.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/read_link_impl.rs
wasmtime-15.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/read_link_impl.rs
wasmtime-14.0.4 ./ext/cargo-vendor/cap-primitives-2.0.0/src/windows/fs/read_link_impl.rs
wasmtime-14.0.3 ./ext/cargo-vendor/cap-primitives-2.0.0/src/windows/fs/read_link_impl.rs
wasmtime-14.0.1 ./ext/cargo-vendor/cap-primitives-2.0.0/src/windows/fs/read_link_impl.rs
wasmtime-14.0.0 ./ext/cargo-vendor/cap-primitives-2.0.0/src/windows/fs/read_link_impl.rs
wasmtime-13.0.0 ./ext/cargo-vendor/cap-primitives-2.0.0/src/windows/fs/read_link_impl.rs
wasmtime-12.0.1 ./ext/cargo-vendor/cap-primitives-2.0.0/src/windows/fs/read_link_impl.rs
wasmtime-12.0.0 ./ext/cargo-vendor/cap-primitives-2.0.0/src/windows/fs/read_link_impl.rs
wasmtime-11.0.0 ./ext/cargo-vendor/cap-primitives-1.0.15/src/windows/fs/read_link_impl.rs
wasmtime-10.0.1 ./ext/cargo-vendor/cap-primitives-1.0.15/src/windows/fs/read_link_impl.rs
wasmtime-10.0.0 ./ext/cargo-vendor/cap-primitives-1.0.15/src/windows/fs/read_link_impl.rs
wasmtime-9.0.4 ./ext/cargo-vendor/cap-primitives-1.0.15/src/windows/fs/read_link_impl.rs
wasmtime-9.0.1 ./ext/cargo-vendor/cap-primitives-1.0.15/src/windows/fs/read_link_impl.rs
wasmtime-8.0.0 ./ext/cargo-vendor/cap-primitives-1.0.14/src/windows/fs/read_link_impl.rs
wasmtime-7.0.0 ./ext/cargo-vendor/cap-primitives-1.0.9/src/windows/fs/read_link_impl.rs