| Crates.io | unix_perms |
| lib.rs | unix_perms |
| version | 0.1.4 |
| created_at | 2025-05-25 16:46:05.236315+00 |
| updated_at | 2025-05-28 19:08:17.739186+00 |
| description | Converts Unix file mode metadata into symbolic rwx strings, emulating the output of the ls -l command. Ideal for Rust-based system tools or file inspection utilities. |
| homepage | https://github.com/santoshxshrestha/unix_perms |
| repository | https://github.com/santoshxshrestha/unix_perms |
| max_upload_size | |
| id | 1688515 |
| size | 6,648 |
A lightweight Rust library for displaying Unix-style file permissions like -rwxr-xr--, mimicking the output of ls -l.
std::fs::Metadata) into symbolic rwx string formatuse unix_perms::display_permissions;
use std::fs::metadata;
fn main() -> std::io::Result<()> {
let meta = metadata("some_file.txt")?;
let mode_str = display_permissions(&meta);
println!("{}", mode_str); // Output: -rw-r--r--
Ok(())
}
use std::fs;
use unix_perms::get_owner_and_group;
fn main() {
let path = ".";
if let Ok(entries) = fs::read_dir(path) {
for entry in entries.flatten() {
let file_name = entry.file_name().into_string().unwrap_or("???".to_string());
let (owner, group) = get_owner_and_group(entry);
println!("{:<20} owner: {:<10} group: {}", file_name, owner, group);
}
}
}
use unix_perms::get_name;
fn main() {
let id = 0;
let name = get_name(id);
println!("{}", name); //Output: root
}
Add this to your Cargo.toml:
[dependencies]
unix_perms = "0.1.0"
or you can directly use cargo
cargo install unix_perms