file_storage/path/properties/
is_folder.rs1use crate::StoragePath;
2
3impl StoragePath {
4 pub fn is_folder(&self) -> bool {
8 self.extension().is_empty() || self.path().ends_with(self.file_separator())
9 }
10}
11
12#[cfg(test)]
13mod tests {
14 use crate::StoragePath;
15
16 #[test]
17 fn is_file_or_folder() {
18 let path: StoragePath = unsafe { StoragePath::new("/the/path", 1, '/') };
19 assert!(!path.is_folder());
20
21 let path: StoragePath = unsafe { StoragePath::new("/the/path/", 1, '/') };
22 assert!(path.is_folder());
23
24 let path: StoragePath = unsafe { StoragePath::new("!", 1, '/') };
25 assert!(path.is_folder());
26 }
27}