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