3 releases
0.1.2 | Sep 4, 2023 |
---|---|
0.1.1 | Dec 17, 2021 |
0.1.0 | Mar 15, 2021 |
#403 in Filesystem
7,109 downloads per month
Used in 11 crates
(8 directly)
16KB
256 lines
Set and get Unix file owner and group.
UID/GUI numbers or user/group names can be used.
Note: This crate will only compile on Unix systems.
use file_owner::PathExt;
"/tmp/baz".set_owner("nobody").unwrap();
"/tmp/baz".set_group("nogroup").unwrap();
let o = "/tmp/baz".owner().unwrap();
o.id(); // 99
o.name(); // Some("nobody")
let g = "/tmp/baz".group().unwrap();
g.id(); // 99
g.name(); // Some("nogroup")
See module level documentation on docs.rs for more examples.
lib.rs
:
Set and get Unix file owner and group.
UID/GUI numbers or user/group names can be used.
Note: This crate will only compile on Unix systems.
Usage examples
Set owner and group by name
use file_owner::PathExt;
"/tmp/baz".set_owner("nobody").unwrap();
"/tmp/baz".set_group("nogroup").unwrap();
Set owner and group by id
use file_owner::PathExt;
"/tmp/baz".set_owner(99).unwrap();
"/tmp/baz".set_group(99).unwrap();
Get owner and group
use file_owner::PathExt;
let o = "/tmp/baz".owner().unwrap();
o.id(); // 99
o.name(); // Some("nobody")
let g = "/tmp/baz".group().unwrap();
g.id(); // 99
g.name(); // Some("nogroup")
Dependencies
~1.5MB
~35K SLoC