forked from mtkennerly/ludusavi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting.rs
55 lines (44 loc) · 1.25 KB
/
testing.rs
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
use std::collections::HashMap;
use maplit::*;
use crate::path::StrictPath;
pub const EMPTY_HASH: &str = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
pub fn repo() -> String {
repo_raw().replace('\\', "/")
}
pub fn repo_raw() -> String {
env!("CARGO_MANIFEST_DIR").to_string()
}
pub fn absolute_path(file: &str) -> StrictPath {
if cfg!(target_os = "windows") {
StrictPath::new(format!("X:{file}"))
} else {
StrictPath::new(file.to_string())
}
}
pub fn mapping_file_key(file: &str) -> String {
if cfg!(target_os = "windows") {
format!("X:{file}")
} else {
file.to_string()
}
}
pub fn drives_x() -> HashMap<String, String> {
if cfg!(target_os = "windows") {
hashmap! { "drive-X".into() => "X:".into() }
} else {
hashmap! { "drive-0".into() => "".into() }
}
}
pub fn drives_x_always() -> HashMap<String, String> {
if cfg!(target_os = "windows") {
hashmap! { "drive-X".into() => "X:".into() }
} else {
hashmap! { "drive-X".into() => "".into() }
}
}
pub fn make_original_path(file: &str) -> StrictPath {
StrictPath::new(format!("{}{file}", if cfg!(target_os = "windows") { "X:" } else { "" }))
}
pub fn s(text: &str) -> String {
text.to_string()
}