Sha256: 98df7ab156c772f8d16176e43a6191926a67c8e0b452d70922a88d38a0bd249a

Contents?: true

Size: 1.13 KB

Versions: 19

Compression:

Stored size: 1.13 KB

Contents

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

/// *Unsandboxed* function similar to `stat`, but which does not perform
/// sandboxing.
pub(crate) fn stat_unchecked(
    start: &fs::File,
    path: &Path,
    follow: FollowSymlinks,
) -> io::Result<Metadata> {
    // Attempt to open the file to get the metadata that way, as that gives
    // us all the info.
    let mut opts = OpenOptions::new();

    // Explicitly request no access, because we're just querying metadata.
    opts.access_mode(0);

    match follow {
        FollowSymlinks::Yes => {
            opts.custom_flags(FILE_FLAG_BACKUP_SEMANTICS);
            opts.follow(FollowSymlinks::Yes);
        }
        FollowSymlinks::No => {
            opts.custom_flags(FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS);
            opts.follow(FollowSymlinks::No);
        }
    }

    let file = open_unchecked(start, path, &opts)?;
    Metadata::from_file(&file)
}

Version data entries

19 entries across 19 versions & 1 rubygems

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