1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use super::dependencies::*;
pub enum PlatformType { Win, Linux }
impl PlatformType {
pub fn detect() -> Self {
match cfg!(windows) {
true => Self::Win,
false => Self::Linux,
}
}
}
pub struct Path {
is_win: bool
}
impl Path {
pub fn new(platform: PlatformType) -> Self {
Self {
is_win: match platform {
PlatformType::Win => true,
_ => false,
}
}
}
fn path_gen<const N: usize>(&self, paths: [&str; N]) -> String {
paths.iter().join(&self.delimetr())
}
pub fn delimetr(&self) -> String {
match self.is_win {
true => "\\",
false => "/",
}.to_string()
}
pub fn root(&self) -> String {
match self.is_win {
true => "C:\\Windows",
false => "/",
}.to_string()
}
pub fn home(&self) -> String {
match self.is_win {
true => "C:\\Users",
false => "/home",
}.to_string()
}
pub fn user(&self) -> String {
let user = get_random_element(USERNAMES.iter());
match self.is_win {
true => user[..1].to_uppercase() + &user[1..],
false => user.to_string(),
}
}
pub fn users_folder(&self) -> String {
let folder = get_random_element(FOLDERS.iter());
self.path_gen([&self.home(), &self.user(), &folder])
}
pub fn dev_dir(&self) -> String {
let folder = get_random_element(vec!["Development", "Dev"].into_iter());
let stack = get_random_element(PROGRAMMING_LANGS.iter());
self.path_gen([&self.home(), &self.user(), folder, stack])
}
pub fn project_dir(&self) -> String {
let project = get_random_element(PROJECT_NAMES.iter());
self.path_gen([&self.dev_dir(), project])
}
}