Skip to main content

DirFd

Struct DirFd 

Source
pub struct DirFd { /* private fields */ }
Expand description

A directory file descriptor that enables safe traversal

Implementations§

Source§

impl DirFd

Source

pub fn open(path: &Path, symlink_behavior: SymlinkBehavior) -> Result<Self>

Open a directory and return a file descriptor

§Arguments
  • path - The path to the directory to open
  • symlink_behavior - Whether to follow symlinks when opening
Source

pub fn open_subdir( &self, name: &OsStr, symlink_behavior: SymlinkBehavior, ) -> Result<Self>

Open a subdirectory relative to this directory

§Arguments
  • name - The name of the subdirectory to open
  • symlink_behavior - Whether to follow symlinks when opening
Source

pub fn stat_at( &self, name: &OsStr, symlink_behavior: SymlinkBehavior, ) -> Result<FileStat>

Get raw stat data for a file relative to this directory

Source

pub fn metadata_at( &self, name: &OsStr, symlink_behavior: SymlinkBehavior, ) -> Result<Metadata>

Get metadata for a file relative to this directory

Source

pub fn metadata(&self) -> Result<Metadata>

Get metadata for this directory

Source

pub fn fstat(&self) -> Result<FileStat>

Get raw stat data for this directory

Source

pub fn read_dir(&self) -> Result<Vec<OsString>>

Read directory entries

Remove a file or empty directory relative to this directory

Source

pub fn chown_at( &self, name: &OsStr, uid: Option<u32>, gid: Option<u32>, symlink_behavior: SymlinkBehavior, ) -> Result<()>

Change ownership of a file relative to this directory Use uid/gid of None to keep the current value

Source

pub fn fchown(&self, uid: Option<u32>, gid: Option<u32>) -> Result<()>

Change ownership of this directory

Source

pub fn chmod_at( &self, name: &OsStr, mode: u32, symlink_behavior: SymlinkBehavior, ) -> Result<()>

Change mode of a file relative to this directory

Source

pub fn fchmod(&self, mode: u32) -> Result<()>

Change mode of this directory

Source

pub fn mkdir_at(&self, name: &OsStr, mode: u32) -> Result<()>

Create a directory relative to this directory

Source

pub fn open_file_at(&self, name: &OsStr) -> Result<File>

Open a file for writing relative to this directory Creates the file if it doesn’t exist, truncates if it does

Source

pub fn from_raw_fd(fd: RawFd) -> Result<Self>

Create a DirFd from an existing file descriptor (takes ownership)

Trait Implementations§

Source§

impl AsFd for DirFd

Source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more
Source§

impl AsRawFd for DirFd

Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more

Auto Trait Implementations§

§

impl Freeze for DirFd

§

impl RefUnwindSafe for DirFd

§

impl Send for DirFd

§

impl Sync for DirFd

§

impl Unpin for DirFd

§

impl UnsafeUnpin for DirFd

§

impl UnwindSafe for DirFd

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.