mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Fixed FsEntry fmt
This commit is contained in:
@@ -194,6 +194,13 @@ impl FsEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ### is_dir
|
||||||
|
///
|
||||||
|
/// Returns whether a FsEntry is a directory
|
||||||
|
pub fn is_dir(&self) -> bool {
|
||||||
|
matches!(self, FsEntry::Directory(_))
|
||||||
|
}
|
||||||
|
|
||||||
/// ### get_realfile
|
/// ### get_realfile
|
||||||
///
|
///
|
||||||
/// Return the real file pointed by a `FsEntry`
|
/// Return the real file pointed by a `FsEntry`
|
||||||
@@ -220,7 +227,10 @@ impl std::fmt::Display for FsEntry {
|
|||||||
let mut mode: String = String::with_capacity(10);
|
let mut mode: String = String::with_capacity(10);
|
||||||
let file_type: char = match self.is_symlink() {
|
let file_type: char = match self.is_symlink() {
|
||||||
true => 'l',
|
true => 'l',
|
||||||
false => 'd',
|
false => match self.is_dir() {
|
||||||
|
true => 'd',
|
||||||
|
false => '-',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
mode.push(file_type);
|
mode.push(file_type);
|
||||||
match self.get_unix_pex() {
|
match self.get_unix_pex() {
|
||||||
@@ -299,6 +309,7 @@ mod tests {
|
|||||||
assert_eq!(entry.get_user(), Some(0));
|
assert_eq!(entry.get_user(), Some(0));
|
||||||
assert_eq!(entry.get_group(), Some(0));
|
assert_eq!(entry.get_group(), Some(0));
|
||||||
assert_eq!(entry.is_symlink(), false);
|
assert_eq!(entry.is_symlink(), false);
|
||||||
|
assert_eq!(entry.is_dir(), true);
|
||||||
assert_eq!(entry.get_unix_pex(), Some((7, 5, 5)));
|
assert_eq!(entry.get_unix_pex(), Some((7, 5, 5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,6 +341,7 @@ mod tests {
|
|||||||
assert_eq!(entry.get_group(), Some(0));
|
assert_eq!(entry.get_group(), Some(0));
|
||||||
assert_eq!(entry.get_unix_pex(), Some((6, 4, 4)));
|
assert_eq!(entry.get_unix_pex(), Some((6, 4, 4)));
|
||||||
assert_eq!(entry.is_symlink(), false);
|
assert_eq!(entry.is_symlink(), false);
|
||||||
|
assert_eq!(entry.is_dir(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -368,7 +380,6 @@ mod tests {
|
|||||||
group: Some(0), // UNIX only
|
group: Some(0), // UNIX only
|
||||||
unix_pex: Some((7, 5, 5)), // UNIX only
|
unix_pex: Some((7, 5, 5)), // UNIX only
|
||||||
});
|
});
|
||||||
assert_eq!(entry.is_symlink(), true);
|
|
||||||
assert_eq!(entry.get_realfile().get_abs_path(), PathBuf::from("/foo"));
|
assert_eq!(entry.get_realfile().get_abs_path(), PathBuf::from("/foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,6 +426,7 @@ mod tests {
|
|||||||
group: Some(0),
|
group: Some(0),
|
||||||
unix_pex: Some((7, 7, 7)),
|
unix_pex: Some((7, 7, 7)),
|
||||||
});
|
});
|
||||||
|
assert_eq!(entry_root.is_symlink(), true);
|
||||||
// get real file
|
// get real file
|
||||||
let real_file: FsEntry = entry_root.get_realfile();
|
let real_file: FsEntry = entry_root.get_realfile();
|
||||||
// real file must be projects in /home/cvisintin
|
// real file must be projects in /home/cvisintin
|
||||||
|
|||||||
Reference in New Issue
Block a user