file_storage/path/system/
is_windows.rs1use crate::{FilePath, FolderPath, StoragePath};
2
3impl StoragePath {
4 pub fn is_windows_path(&self) -> bool {
8 Self::is_windows_path_str(self.path())
9 }
10
11 pub fn is_windows_path_str<S>(path: S) -> bool
13 where
14 S: AsRef<str>,
15 {
16 let path: &str = path.as_ref();
17 if path.len() < 3 {
18 false
19 } else {
20 path.as_bytes()[0].is_ascii_alphabetic()
21 && path.as_bytes()[1] == b':'
22 && (path.as_bytes()[2] == b'\\' || path.as_bytes()[2] == b'/')
23 }
24 }
25}
26
27impl FilePath {
28 pub fn is_windows_path(&self) -> bool {
32 StoragePath::is_windows_path_str(self.as_str())
33 }
34}
35
36impl FolderPath {
37 pub fn is_windows_path(&self) -> bool {
41 StoragePath::is_windows_path_str(self.as_str())
42 }
43}