Sha256: 6a56654df7718bc2c22fb68dbda9e44c2b8b537775d271d040ebf816a1b52236

Contents?: true

Size: 1.28 KB

Versions: 25

Compression:

Stored size: 1.28 KB

Contents

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

#[inline]
pub(crate) fn set_times_impl(
    start: &fs::File,
    path: &Path,
    atime: Option<SystemTimeSpec>,
    mtime: Option<SystemTimeSpec>,
) -> io::Result<()> {
    set_times_inner(start, path, atime, mtime, 0)
}

#[inline]
pub(crate) fn set_times_nofollow_impl(
    start: &fs::File,
    path: &Path,
    atime: Option<SystemTimeSpec>,
    mtime: Option<SystemTimeSpec>,
) -> io::Result<()> {
    set_times_inner(start, path, atime, mtime, FILE_FLAG_OPEN_REPARSE_POINT)
}

fn set_times_inner(
    start: &fs::File,
    path: &Path,
    atime: Option<SystemTimeSpec>,
    mtime: Option<SystemTimeSpec>,
    custom_flags: u32,
) -> io::Result<()> {
    let custom_flags = custom_flags | FILE_FLAG_BACKUP_SEMANTICS;

    // On Windows, `set_times` requires write permissions.
    let file = open(
        start,
        path,
        OpenOptions::new().write(true).custom_flags(custom_flags),
    )?;
    fs_set_times::SetTimes::set_times(
        &file,
        atime.map(SystemTimeSpec::into_std),
        mtime.map(SystemTimeSpec::into_std),
    )
}

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/set_times_impl.rs
wasmtime-17.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/set_times_impl.rs
wasmtime-17.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/set_times_impl.rs
wasmtime-16.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/set_times_impl.rs
wasmtime-15.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/set_times_impl.rs
wasmtime-15.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/set_times_impl.rs
wasmtime-14.0.4 ./ext/cargo-vendor/cap-primitives-2.0.0/src/windows/fs/set_times_impl.rs
wasmtime-14.0.3 ./ext/cargo-vendor/cap-primitives-2.0.0/src/windows/fs/set_times_impl.rs
wasmtime-14.0.1 ./ext/cargo-vendor/cap-primitives-2.0.0/src/windows/fs/set_times_impl.rs
wasmtime-14.0.0 ./ext/cargo-vendor/cap-primitives-2.0.0/src/windows/fs/set_times_impl.rs
wasmtime-13.0.0 ./ext/cargo-vendor/cap-primitives-2.0.0/src/windows/fs/set_times_impl.rs
wasmtime-12.0.1 ./ext/cargo-vendor/cap-primitives-2.0.0/src/windows/fs/set_times_impl.rs
wasmtime-12.0.0 ./ext/cargo-vendor/cap-primitives-2.0.0/src/windows/fs/set_times_impl.rs
wasmtime-11.0.0 ./ext/cargo-vendor/cap-primitives-1.0.15/src/windows/fs/set_times_impl.rs
wasmtime-10.0.1 ./ext/cargo-vendor/cap-primitives-1.0.15/src/windows/fs/set_times_impl.rs
wasmtime-10.0.0 ./ext/cargo-vendor/cap-primitives-1.0.15/src/windows/fs/set_times_impl.rs
wasmtime-9.0.4 ./ext/cargo-vendor/cap-primitives-1.0.15/src/windows/fs/set_times_impl.rs
wasmtime-9.0.1 ./ext/cargo-vendor/cap-primitives-1.0.15/src/windows/fs/set_times_impl.rs
wasmtime-8.0.0 ./ext/cargo-vendor/cap-primitives-1.0.14/src/windows/fs/set_times_impl.rs
wasmtime-7.0.0 ./ext/cargo-vendor/cap-primitives-1.0.9/src/windows/fs/set_times_impl.rs