luaur_cli_lib/functions/is_absolute_path.rs
1pub fn is_absolute_path(path: &str) -> bool {
2 #[cfg(windows)]
3 {
4 let bytes = path.as_bytes();
5 (bytes.len() >= 3
6 && bytes[0].is_ascii_alphabetic()
7 && bytes[1] == b':'
8 && (bytes[2] == b'/' || bytes[2] == b'\\'))
9 || (bytes.len() >= 1 && (bytes[0] == b'/' || bytes[0] == b'\\'))
10 }
11 #[cfg(not(windows))]
12 {
13 let bytes = path.as_bytes();
14 bytes.len() >= 1 && bytes[0] == b'/'
15 }
16}