Skip to main content

PathExt

Trait PathExt 

Source
pub trait PathExt {
    // Required methods
    fn readable(&self) -> bool;
    fn writable(&self) -> bool;
    fn executable(&self) -> bool;
    fn exists_and_is_block_device(&self) -> bool;
    fn exists_and_is_char_device(&self) -> bool;
    fn exists_and_is_fifo(&self) -> bool;
    fn exists_and_is_socket(&self) -> bool;
    fn exists_and_is_setgid(&self) -> bool;
    fn exists_and_is_setuid(&self) -> bool;
    fn exists_and_is_sticky_bit(&self) -> bool;
    fn get_device_and_inode(&self) -> Result<(u64, u64), Error>;
}
Expand description

Extension trait for path-related filesystem operations.

Required Methods§

Source

fn readable(&self) -> bool

Returns true if the path exists and is readable by the current user.

Source

fn writable(&self) -> bool

Returns true if the path exists and is writable by the current user.

Source

fn executable(&self) -> bool

Returns true if the path exists and is executable by the current user.

On Windows, this returns true if either the path itself is a file with a PATHEXT extension or appending some PATHEXT extension resolves to an existing file. To recover the actual on-disk path in the latter case, use resolve_executable which takes ownership and avoids copies on platforms where no resolution is needed.

Source

fn exists_and_is_block_device(&self) -> bool

Returns true if the path exists and is a block device.

Source

fn exists_and_is_char_device(&self) -> bool

Returns true if the path exists and is a character device.

Source

fn exists_and_is_fifo(&self) -> bool

Returns true if the path exists and is a FIFO (named pipe).

Source

fn exists_and_is_socket(&self) -> bool

Returns true if the path exists and is a socket.

Source

fn exists_and_is_setgid(&self) -> bool

Returns true if the path exists and has the setgid bit set.

Source

fn exists_and_is_setuid(&self) -> bool

Returns true if the path exists and has the setuid bit set.

Source

fn exists_and_is_sticky_bit(&self) -> bool

Returns true if the path exists and has the sticky bit set.

Source

fn get_device_and_inode(&self) -> Result<(u64, u64), Error>

Returns the device ID and inode number for the path.

§Errors

Returns crate::error::ErrorKind::IoError if the path’s metadata cannot be read, for example because it does not exist. Platforms that cannot report device and inode numbers return crate::error::ErrorKind::NotSupportedOnThisPlatform or placeholder values.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl PathExt for Path

Available on Unix only.

Implementors§