pub struct DirFd { /* private fields */ }Expand description
A directory file descriptor that enables safe traversal
Implementations§
Source§impl DirFd
impl DirFd
Sourcepub fn open(path: &Path, symlink_behavior: SymlinkBehavior) -> Result<Self>
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 opensymlink_behavior- Whether to follow symlinks when opening
Sourcepub fn open_subdir(
&self,
name: &OsStr,
symlink_behavior: SymlinkBehavior,
) -> Result<Self>
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 opensymlink_behavior- Whether to follow symlinks when opening
Sourcepub fn stat_at(
&self,
name: &OsStr,
symlink_behavior: SymlinkBehavior,
) -> Result<FileStat>
pub fn stat_at( &self, name: &OsStr, symlink_behavior: SymlinkBehavior, ) -> Result<FileStat>
Get raw stat data for a file relative to this directory
Sourcepub fn metadata_at(
&self,
name: &OsStr,
symlink_behavior: SymlinkBehavior,
) -> Result<Metadata>
pub fn metadata_at( &self, name: &OsStr, symlink_behavior: SymlinkBehavior, ) -> Result<Metadata>
Get metadata for a file relative to this directory
Sourcepub fn unlink_at(&self, name: &OsStr, is_dir: bool) -> Result<()>
pub fn unlink_at(&self, name: &OsStr, is_dir: bool) -> Result<()>
Remove a file or empty directory relative to this directory
Sourcepub fn chown_at(
&self,
name: &OsStr,
uid: Option<u32>,
gid: Option<u32>,
symlink_behavior: SymlinkBehavior,
) -> Result<()>
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
Sourcepub fn fchown(&self, uid: Option<u32>, gid: Option<u32>) -> Result<()>
pub fn fchown(&self, uid: Option<u32>, gid: Option<u32>) -> Result<()>
Change ownership of this directory
Sourcepub fn chmod_at(
&self,
name: &OsStr,
mode: u32,
symlink_behavior: SymlinkBehavior,
) -> Result<()>
pub fn chmod_at( &self, name: &OsStr, mode: u32, symlink_behavior: SymlinkBehavior, ) -> Result<()>
Change mode of a file relative to this directory
Sourcepub fn mkdir_at(&self, name: &OsStr, mode: u32) -> Result<()>
pub fn mkdir_at(&self, name: &OsStr, mode: u32) -> Result<()>
Create a directory relative to this directory
Sourcepub fn open_file_at(&self, name: &OsStr) -> Result<File>
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
Sourcepub fn from_raw_fd(fd: RawFd) -> Result<Self>
pub fn from_raw_fd(fd: RawFd) -> Result<Self>
Create a DirFd from an existing file descriptor (takes ownership)
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more