summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/fs/cwd.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/src/fs/cwd.rs')
-rw-r--r--vendor/rustix/src/fs/cwd.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/vendor/rustix/src/fs/cwd.rs b/vendor/rustix/src/fs/cwd.rs
index 0abd75df6..2745060a1 100644
--- a/vendor/rustix/src/fs/cwd.rs
+++ b/vendor/rustix/src/fs/cwd.rs
@@ -8,23 +8,32 @@
#![allow(unsafe_code)]
use crate::backend;
+use backend::c;
use backend::fd::{BorrowedFd, RawFd};
-/// `AT_FDCWD`—Returns a handle representing the current working directory.
+/// `AT_FDCWD`—A handle representing the current working directory.
///
-/// This returns a file descriptor which refers to the process current
-/// directory which can be used as the directory argument in `*at`
-/// functions such as [`openat`].
+/// This is a file descriptor which refers to the process current directory
+/// which can be used as the directory argument in `*at` functions such as
+/// [`openat`].
///
/// # References
/// - [POSIX]
///
/// [`openat`]: crate::fs::openat
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html
-#[inline]
+// SAFETY: `AT_FDCWD` is a reserved value that is never dynamically
+// allocated, so it'll remain valid for the duration of `'static`.
#[doc(alias = "AT_FDCWD")]
+#[cfg(not(target_os = "haiku"))] // Haiku needs <https://github.com/rust-lang/rust/pull/112371>
+pub const CWD: BorrowedFd<'static> =
+ unsafe { BorrowedFd::<'static>::borrow_raw(c::AT_FDCWD as RawFd) };
+
+/// Return the value of [`CWD`].
+#[deprecated(note = "Use `CWD` in place of `cwd()`.")]
+#[cfg(not(target_os = "haiku"))] // Haiku needs <https://github.com/rust-lang/rust/pull/112371>
pub const fn cwd() -> BorrowedFd<'static> {
- let at_fdcwd = backend::io::types::AT_FDCWD as RawFd;
+ 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`.