use crate::StoragePath;
impl StoragePath {
pub fn is_local_path(&self) -> bool {
Self::is_local_path_str(self.path())
}
pub fn is_local_path_str<S>(path: S) -> bool
where
S: AsRef<str>,
{
let path: &str = path.as_ref();
if cfg!(windows) {
Self::is_windows_path_str(path)
} else {
Self::is_unix_path_str(path)
}
}
}
#[cfg(test)]
mod tests {
use crate::StoragePath;
#[test]
fn is_local_path_str() {
let is_local = |path: &str| -> bool { StoragePath::is_local_path_str(path) };
let on_windows: bool = cfg!(windows);
assert_eq!(is_local("/unix/path"), !on_windows);
assert_eq!(is_local("C:\\windows\\path"), on_windows);
assert_eq!(is_local("\\\\server\\share"), on_windows);
assert!(!is_local("https://example.com/bucket/"));
assert!(!is_local("relative"));
assert!(!is_local(""));
}
}