file_storage/path/system/
is_local.rs1use crate::StoragePath;
2
3impl StoragePath {
4 pub fn is_local_path(&self) -> bool {
8 Self::is_local_path_str(self.path())
9 }
10
11 pub fn is_local_path_str<S>(path: S) -> bool
13 where
14 S: AsRef<str>,
15 {
16 let path: &str = path.as_ref();
17 StoragePath::is_unix_path_str(path) || StoragePath::is_windows_path_str(path)
18 }
19}
20
21#[cfg(test)]
22mod tests {
23 use crate::StoragePath;
24
25 #[test]
26 fn is_local_path_str() {
27 assert!(StoragePath::is_local_path_str("/unix/path"));
28 assert!(StoragePath::is_local_path_str("C:\\windows\\path"));
29 assert!(StoragePath::is_local_path_str("\\\\server\\share"));
30
31 assert!(!StoragePath::is_local_path_str("https://example.com/bucket/"));
32 assert!(!StoragePath::is_local_path_str("relative"));
33 assert!(!StoragePath::is_local_path_str(""));
34 }
35}