2 releases

0.1.1 Dec 17, 2021
0.1.0 Mar 15, 2021

#144 in Unix APIs

Download history 3/week @ 2022-02-05 5/week @ 2022-02-12 10/week @ 2022-02-19 6/week @ 2022-02-26 13/week @ 2022-03-05 10/week @ 2022-03-12 13/week @ 2022-03-19 28/week @ 2022-03-26 24/week @ 2022-04-02 13/week @ 2022-04-09 22/week @ 2022-04-16 24/week @ 2022-04-23 21/week @ 2022-04-30 27/week @ 2022-05-07 60/week @ 2022-05-14 25/week @ 2022-05-21

133 downloads per month
Used in 4 crates (2 directly)

MIT license

15KB
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
~27K SLoC