1extern crate libc;
2
3pub mod config;
4pub mod error;
5pub mod installer;
6pub mod makefile;
7pub mod validator;
8
9use crate::config::{SKIN_CONFIG_DIRECTORY, SKIN_SKINNERS_DIRECTORY, SKIN_TEMP_DIRECTORY};
10use std::fs;
11
12pub fn setup_config_dir(custom_path: Option<&str>) -> Result<(), std::io::Error> {
13 for s_path in [
14 SKIN_CONFIG_DIRECTORY,
15 SKIN_SKINNERS_DIRECTORY,
16 SKIN_TEMP_DIRECTORY,
17 ] {
18 let path = custom_path.unwrap_or(s_path);
19 let expanded_path = shellexpand::tilde(path).into_owned();
20
21 if fs::metadata(&expanded_path).is_err() {
22 fs::create_dir_all(&expanded_path)?;
23 }
24 }
25
26 Ok(())
27}
28
29pub fn as_root() -> bool {
30 let uid = unsafe { libc::getuid() };
31 uid == 0
32}