Sha256: 3400dd3954aa0d806af1960054899447de5e425481edfad539bdd5fd0b9967d8

Contents?: true

Size: 661 Bytes

Versions: 3

Compression:

Stored size: 661 Bytes

Contents

//! The `cwd` function, representing the current working directory.
//!
//! # Safety
//!
//! This file uses `AT_FDCWD`, which is a raw file descriptor, but which is
//! always valid.

#![allow(unsafe_code)]

use crate::backend;
use backend::c;
use backend::fd::{BorrowedFd, RawFd};

/// Return the value of [`CWD`].
#[deprecated(note = "Use `CWD` in place of `cwd()`.")]
pub const fn cwd() -> BorrowedFd<'static> {
    let at_fdcwd = c::AT_FDCWD as RawFd;

    // SAFETY: `AT_FDCWD` is a reserved value that is never dynamically
    // allocated, so it'll remain valid for the duration of `'static`.
    unsafe { BorrowedFd::<'static>::borrow_raw(at_fdcwd) }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/rustix-0.38.44/src/fs/cwd.rs
wasmtime-28.0.0 ./ext/cargo-vendor/rustix-0.38.43/src/fs/cwd.rs
wasmtime-27.0.0 ./ext/cargo-vendor/rustix-0.38.41/src/fs/cwd.rs