Sha256: a53ae2355dd8ec3bf73ab13acabafa13dafa9b2dc622be49b2fd5e27cab650e3

Contents?: true

Size: 1.02 KB

Versions: 39

Compression:

Stored size: 1.02 KB

Contents

use super::get_path::get_path;
use std::{fs, io};

pub(crate) fn remove_open_dir_impl(dir: fs::File) -> io::Result<()> {
    let path = get_path(&dir)?;

    // Drop the directory before removing it, since we open directories without
    // `FILE_SHARE_DELETE`, and removing it requires accessing via its name
    // rather than its handle.
    //
    // There is a window here in which another process could remove or rename
    // a directory with this path after the handle is dropped, however it's
    // unlikely to happen by accident, and unlikely to cause major problems.
    // It may cause spurious failures, or failures with different error codes,
    // but this appears to be unavoidable.
    //
    // Even if we did have `FILE_SHARE_DELETE` and we kept the handle open
    // while doing the `remove_dir, `FILE_SHARE_DELETE` would grant other
    // processes the right to remove or rename the directory. So there
    // doesn't seem to be a race-free way of removing opened directories.
    drop(dir);

    fs::remove_dir(path)
}

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
wasmtime-30.0.2 ./ext/cargo-vendor/cap-primitives-3.4.2/src/windows/fs/remove_open_dir_impl.rs
wasmtime-29.0.0 ./ext/cargo-vendor/cap-primitives-3.4.2/src/windows/fs/remove_open_dir_impl.rs
wasmtime-28.0.0 ./ext/cargo-vendor/cap-primitives-3.4.2/src/windows/fs/remove_open_dir_impl.rs
wasmtime-27.0.0 ./ext/cargo-vendor/cap-primitives-3.4.1/src/windows/fs/remove_open_dir_impl.rs
wasmtime-26.0.0 ./ext/cargo-vendor/cap-primitives-3.3.0/src/windows/fs/remove_open_dir_impl.rs
wasmtime-25.0.2 ./ext/cargo-vendor/cap-primitives-3.2.0/src/windows/fs/remove_open_dir_impl.rs
wasmtime-25.0.1 ./ext/cargo-vendor/cap-primitives-3.2.0/src/windows/fs/remove_open_dir_impl.rs
wasmtime-25.0.0 ./ext/cargo-vendor/cap-primitives-3.2.0/src/windows/fs/remove_open_dir_impl.rs
wasmtime-24.0.0 ./ext/cargo-vendor/cap-primitives-3.2.0/src/windows/fs/remove_open_dir_impl.rs
wasmtime-23.0.2 ./ext/cargo-vendor/cap-primitives-3.1.0/src/windows/fs/remove_open_dir_impl.rs
wasmtime-22.0.0 ./ext/cargo-vendor/cap-primitives-3.1.0/src/windows/fs/remove_open_dir_impl.rs
wasmtime-21.0.1 ./ext/cargo-vendor/cap-primitives-3.1.0/src/windows/fs/remove_open_dir_impl.rs
wasmtime-20.0.2 ./ext/cargo-vendor/cap-primitives-3.1.0/src/windows/fs/remove_open_dir_impl.rs
wasmtime-20.0.0 ./ext/cargo-vendor/cap-primitives-3.0.0/src/windows/fs/remove_open_dir_impl.rs
wasmtime-18.0.3 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/remove_open_dir_impl.rs
wasmtime-17.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/remove_open_dir_impl.rs
wasmtime-17.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/remove_open_dir_impl.rs
wasmtime-16.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/remove_open_dir_impl.rs
wasmtime-15.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/remove_open_dir_impl.rs
wasmtime-15.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/windows/fs/remove_open_dir_impl.rs