Sha256: 58218eaec9233da7daeace3ba86b8dac3dae96bd79e0b6222647f85072f42722

Contents?: true

Size: 1.25 KB

Versions: 13

Compression:

Stored size: 1.25 KB

Contents

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

13 entries across 13 versions & 1 rubygems

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