From d0774fd7edd11509b24802136150f5a2c2862c1a Mon Sep 17 00:00:00 2001 From: ChristianVisintin Date: Sat, 19 Dec 2020 21:38:56 +0100 Subject: [PATCH] FsEntry::is_file --- src/fs/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/fs/mod.rs b/src/fs/mod.rs index 41272b8..cd70851 100644 --- a/src/fs/mod.rs +++ b/src/fs/mod.rs @@ -201,6 +201,13 @@ impl FsEntry { matches!(self, FsEntry::Directory(_)) } + /// ### is_file + /// + /// Returns whether a FsEntry is a File + pub fn is_file(&self) -> bool { + matches!(self, FsEntry::File(_)) + } + /// ### get_realfile /// /// Return the real file pointed by a `FsEntry` @@ -310,6 +317,7 @@ mod tests { assert_eq!(entry.get_group(), Some(0)); assert_eq!(entry.is_symlink(), false); assert_eq!(entry.is_dir(), true); + assert_eq!(entry.is_file(), false); assert_eq!(entry.get_unix_pex(), Some((7, 5, 5))); } @@ -342,6 +350,7 @@ mod tests { assert_eq!(entry.get_unix_pex(), Some((6, 4, 4))); assert_eq!(entry.is_symlink(), false); assert_eq!(entry.is_dir(), false); + assert_eq!(entry.is_file(), true); } #[test]