Struct openat::Dir
[−]
[src]
pub struct Dir(_);
A safe wrapper around directory file descriptor
Construct it either with Dir::cwd()
or Dir::open(path)
Methods
impl Dir
[src]
pub fn cwd() -> Dir
[src]
Creates a directory descriptor that resolves paths relative to current workding directory (AT_FDCWD)
pub fn open<P: AsPath>(path: P) -> Result<Dir>
[src]
Open a directory descriptor at specified path
pub fn list_dir<P: AsPath>(&self, path: P) -> Result<DirIter>
[src]
List subdirectory of this dir
You can list directory itself if "."
is specified as path.
pub fn sub_dir<P: AsPath>(&self, path: P) -> Result<Dir>
[src]
Open subdirectory
pub fn read_link<P: AsPath>(&self, path: P) -> Result<PathBuf>
[src]
Read link in this directory
pub fn open_file<P: AsPath>(&self, path: P) -> Result<File>
[src]
Open file for reading in this directory
pub fn write_file<P: AsPath>(&self, path: P, mode: mode_t) -> Result<File>
[src]
Open file for writing, create if necessary, truncate on open
pub fn append_file<P: AsPath>(&self, path: P, mode: mode_t) -> Result<File>
[src]
Open file for append, create if necessary
pub fn create_file<P: AsPath>(&self, path: P, mode: mode_t) -> Result<File>
[src]
: please use write_file
instead
Create file for writing (and truncate) in this directory
Deprecated alias for write_file
pub fn new_file<P: AsPath>(&self, path: P, mode: mode_t) -> Result<File>
[src]
Create file if not exists, fail if exists
This function checks existence and creates file atomically with respect to other threads and processes.
Technically it means passing O_EXCL
flag to open.
pub fn update_file<P: AsPath>(&self, path: P, mode: mode_t) -> Result<File>
[src]
Open file for reading and writing without truncation, create if needed
pub fn symlink<P: AsPath, R: AsPath>(&self, path: P, value: R) -> Result<()>
[src]
Make a symlink in this directory
Note: the order of arguments differ from symlinkat
pub fn create_dir<P: AsPath>(&self, path: P, mode: mode_t) -> Result<()>
[src]
Create a subdirectory in this directory
pub fn local_rename<P: AsPath, R: AsPath>(&self, old: P, new: R) -> Result<()>
[src]
Rename a file in this directory to another name (keeping same dir)
pub fn remove_dir<P: AsPath>(&self, path: P) -> Result<()>
[src]
Remove a subdirectory in this directory
Note only empty directory may be removed
pub fn remove_file<P: AsPath>(&self, path: P) -> Result<()>
[src]
Remove a file in this directory
pub fn recover_path(&self) -> Result<PathBuf>
[src]
Get the path of this directory (if possible)
This uses symlinks in /proc/self
, they sometimes may not be
available so use with care.
pub fn metadata<P: AsPath>(&self, path: P) -> Result<Metadata>
[src]
Returns metadata of an entry in this directory
Trait Implementations
impl AsRawFd for Dir
[src]
impl FromRawFd for Dir
[src]
unsafe fn from_raw_fd(fd: RawFd) -> Dir
[src]
Constructs a new instance of Self
from the given raw file descriptor. Read more
impl IntoRawFd for Dir
[src]
fn into_raw_fd(self) -> RawFd
[src]
Consumes this object, returning the raw underlying file descriptor. Read more