Sha256: e2da60815c9872013f5fdb09c283aef26a819af4315b05b4dc5e758d15e82de2

Contents?: true

Size: 876 Bytes

Versions: 13

Compression:

Stored size: 876 Bytes

Contents

use crate::fs::{open, FollowSymlinks, OpenOptions, 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

13 entries across 13 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/cap-primitives-3.4.2/src/windows/fs/read_link_impl.rs
wasmtime-28.0.0 ./ext/cargo-vendor/cap-primitives-3.4.2/src/windows/fs/read_link_impl.rs
wasmtime-27.0.0 ./ext/cargo-vendor/cap-primitives-3.4.1/src/windows/fs/read_link_impl.rs
wasmtime-26.0.0 ./ext/cargo-vendor/cap-primitives-3.3.0/src/windows/fs/read_link_impl.rs
wasmtime-25.0.2 ./ext/cargo-vendor/cap-primitives-3.2.0/src/windows/fs/read_link_impl.rs
wasmtime-25.0.1 ./ext/cargo-vendor/cap-primitives-3.2.0/src/windows/fs/read_link_impl.rs
wasmtime-25.0.0 ./ext/cargo-vendor/cap-primitives-3.2.0/src/windows/fs/read_link_impl.rs
wasmtime-24.0.0 ./ext/cargo-vendor/cap-primitives-3.2.0/src/windows/fs/read_link_impl.rs
wasmtime-23.0.2 ./ext/cargo-vendor/cap-primitives-3.1.0/src/windows/fs/read_link_impl.rs
wasmtime-22.0.0 ./ext/cargo-vendor/cap-primitives-3.1.0/src/windows/fs/read_link_impl.rs
wasmtime-21.0.1 ./ext/cargo-vendor/cap-primitives-3.1.0/src/windows/fs/read_link_impl.rs
wasmtime-20.0.2 ./ext/cargo-vendor/cap-primitives-3.1.0/src/windows/fs/read_link_impl.rs
wasmtime-20.0.0 ./ext/cargo-vendor/cap-primitives-3.0.0/src/windows/fs/read_link_impl.rs