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
[src]
Creates a directory descriptor that resolves paths relative to current workding directory (AT_FDCWD)
fn open<P: AsPath>(path: P) -> Result<Dir>
[src]
Open a directory descriptor at specified path
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.
fn sub_dir<P: AsPath>(&self, path: P) -> Result<Dir>
[src]
Open subdirectory
fn read_link<P: AsPath>(&self, path: P) -> Result<PathBuf>
[src]
Read link in this directory
fn open_file<P: AsPath>(&self, path: P) -> Result<File>
[src]
Open file for reading in this directory
fn write_file<P: AsPath>(&self, path: P, mode: mode_t) -> Result<File>
[src]
Open file for writing, create if necessary, truncate on open
fn append_file<P: AsPath>(&self, path: P, mode: mode_t) -> Result<File>
[src]
Open file for append, create if necessary
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
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.
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
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
fn create_dir<P: AsPath>(&self, path: P, mode: mode_t) -> Result<()>
[src]
Create a subdirectory in this directory
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)
fn remove_dir<P: AsPath>(&self, path: P) -> Result<()>
[src]
Remove a subdirectory in this directory
Note only empty directory may be removed
fn remove_file<P: AsPath>(&self, path: P) -> Result<()>
[src]
Remove a file in this directory
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.
fn metadata<P: AsPath>(&self, path: P) -> Result<Metadata>
[src]
Returns metadata of an entry in this directory