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]
fn cwd() -> Dir
Creates a directory descriptor that resolves paths relative to current workding directory (AT_FDCWD)
fn open<P: AsPath>(path: P) -> Result<Dir>
Open a directory descriptor at specified path
fn list_dir<P: AsPath>(&self, path: P) -> Result<DirIter>
List subdirectory of this dir
You can list directory itself if "."
is specified as path.
fn sub_dir<P: AsPath>(&self, path: P) -> Result<Dir>
Open subdirectory
fn read_link<P: AsPath>(&self, path: P) -> Result<PathBuf>
Read link in this directory
fn open_file<P: AsPath>(&self, path: P) -> Result<File>
Open file for reading in this directory
fn create_file<P: AsPath>(&self, path: P, mode: mode_t) -> Result<File>
Create file for writing (and truncate) in this directory
fn symlink<P: AsPath, R: AsPath>(&self, path: P, value: P) -> Result<()>
Make a symlink in this directory
Note: the order of arguments differ from symlinkat
fn create_dir<P: AsPath>(&self, path: P, mode: mode_t) -> Result<()>
Create a subdirectory in this directory
fn local_rename<P: AsPath, R: AsPath>(&self, old: P, new: R) -> Result<()>
Rename a file in this directory to another name (keeping same dir)
fn remove_dir<P: AsPath>(&self, path: P) -> Result<()>
Remove a subdirectory in this directory
Note only empty directory may be removed
fn remove_file<P: AsPath>(&self, path: P) -> Result<()>
Remove a file in this directory
fn recover_path(&self) -> Result<PathBuf>
Get the path of this directory (if possible)
This uses symlinks in /proc/self
, they sometimes may not be
available so use with care.
fn metadata<P: AsPath>(&self, path: P) -> Result<Metadata>
Returns metadata of an entry in this directory