Struct nix::dir::Dir [−][src]
pub struct Dir(_);
An open directory.
This is a lower-level interface than std::fs::ReadDir. Notable differences:
- can be opened from a file descriptor (as returned by
openat, perhaps before knowing if the path represents a file or directory). - implements
AsRawFd, so it can be passed tofstat,openat, etc. The file descriptor continues to be owned by theDir, so callers must not keep aRawFdafter theDiris dropped. - can be iterated through multiple times without closing and reopening the file descriptor. Each iteration rewinds when finished.
- returns entries for
.(current directory) and..(parent directory). - returns entries’ names as a
CStr(no allocation or conversion beyond whatever libc does).
Implementations
impl Dir[src]
impl Dir[src]pub fn open<P: ?Sized + NixPath>(
path: &P,
oflag: OFlag,
mode: Mode
) -> Result<Self>[src]
path: &P,
oflag: OFlag,
mode: Mode
) -> Result<Self>
Opens the given path as with fcntl::open.
pub fn openat<P: ?Sized + NixPath>(
dirfd: RawFd,
path: &P,
oflag: OFlag,
mode: Mode
) -> Result<Self>[src]
dirfd: RawFd,
path: &P,
oflag: OFlag,
mode: Mode
) -> Result<Self>
Opens the given path as with fcntl::openat.
pub fn from<F: IntoRawFd>(fd: F) -> Result<Self>[src]
Converts from a descriptor-based object, closing the descriptor on success or failure.
pub fn from_fd(fd: RawFd) -> Result<Self>[src]
Converts from a file descriptor, closing it on success or failure.
pub fn iter(&mut self) -> Iter<'_>ⓘ[src]
Returns an iterator of Result<Entry> which rewinds when finished.