brush_core/sys/fs.rs
1//! Filesystem utilities
2
3pub use super::platform::fs::*;
4
5/// Extension trait for path-related filesystem operations.
6pub trait PathExt {
7 /// Returns true if the path exists and is readable by the current user.
8 fn readable(&self) -> bool;
9 /// Returns true if the path exists and is writable by the current user.
10 fn writable(&self) -> bool;
11 /// Returns true if the path exists and is executable by the current user.
12 ///
13 /// On Windows, this returns true if *either* the path itself is a file with
14 /// a `PATHEXT` extension *or* appending some `PATHEXT` extension resolves
15 /// to an existing file. To recover the actual on-disk path in the
16 /// latter case, use [`resolve_executable`] which takes ownership
17 /// and avoids copies on platforms where no resolution is needed.
18 fn executable(&self) -> bool;
19
20 /// Returns true if the path exists and is a block device.
21 fn exists_and_is_block_device(&self) -> bool;
22 /// Returns true if the path exists and is a character device.
23 fn exists_and_is_char_device(&self) -> bool;
24 /// Returns true if the path exists and is a FIFO (named pipe).
25 fn exists_and_is_fifo(&self) -> bool;
26 /// Returns true if the path exists and is a socket.
27 fn exists_and_is_socket(&self) -> bool;
28 /// Returns true if the path exists and has the setgid bit set.
29 fn exists_and_is_setgid(&self) -> bool;
30 /// Returns true if the path exists and has the setuid bit set.
31 fn exists_and_is_setuid(&self) -> bool;
32 /// Returns true if the path exists and has the sticky bit set.
33 fn exists_and_is_sticky_bit(&self) -> bool;
34
35 /// Returns the device ID and inode number for the path.
36 fn get_device_and_inode(&self) -> Result<(u64, u64), crate::error::Error>;
37}