Sha256: b826a5fad194f05c5a179f196a1cc00d8d52e827150fdeed33f191ea587a84e9

Contents?: true

Size: 1.12 KB

Versions: 13

Compression:

Stored size: 1.12 KB

Contents

use crate::fs::OpenOptionsExt;
use crate::fs::{open_unchecked, FollowSymlinks, Metadata, OpenOptions};
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

13 entries across 13 versions & 1 rubygems

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