3 releases

0.1.2 Sep 4, 2023
0.1.1 Dec 17, 2021
0.1.0 Mar 15, 2021

#403 in Filesystem

Download history 1824/week @ 2024-07-21 1505/week @ 2024-07-28 1767/week @ 2024-08-04 2865/week @ 2024-08-11 2549/week @ 2024-08-18 2421/week @ 2024-08-25 2479/week @ 2024-09-01 2408/week @ 2024-09-08 2208/week @ 2024-09-15 2019/week @ 2024-09-22 2208/week @ 2024-09-29 2319/week @ 2024-10-06 1587/week @ 2024-10-13 1979/week @ 2024-10-20 1900/week @ 2024-10-27 1535/week @ 2024-11-03

7,109 downloads per month
Used in 11 crates (8 directly)

MIT license

16KB
256 lines

Latest Version Documentation License

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