[−][src]Crate unix_mode
Manipulate Unix file mode bits.
Every filesystem entry (or inode) on Unix has a bit field of mode bits that describe both the type of the file and its permissions.
These are classically displayed in the left of ls
output, and the permissions
can be changed with chmod
. For example:
assert_eq!(unix_mode::to_string(0o0040755), "drwxr-xr-x"); assert_eq!(unix_mode::to_string(0o0100640), "-rw-r-----");
The encoding is fairly standard across unices, and occurs in some file formats and network protocols that might be seen on non-Unix platforms.
This library isn't Unix-specific and doesn't depend on the underlying OS to interpret the bits.
For example, this can be used with the return value from
std::os::unix::fs::MetadataExt::mode()
.
The names of the predicate functions match std::fs::FileType
and
std::os::unix::fs::FileTypeExt
.
Functions
is_block_device | Returns true if this mode represents a block device. |
is_char_device | Returns true if this mode represents a character device. |
is_dir | Returns true if this mode represents a directory. |
is_fifo | Returns true if this mode represents a fifo, also known as a named pipe. |
is_file | Returns true if this mode represents a regular file. |
is_socket | Returns true if this mode represents a Unix-domain socket. |
is_symlink | Returns true if this mode represents a symlink. |
to_string | Convert Unix mode bits to a text string describing type and permissions,
as shown in |