1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

tests/common/util: add AtPath::symlink_exists()

Add helper method for deciding whether a symbolic link exists in the
test directory.
This commit is contained in:
Jeffrey Finkelstein 2022-07-03 13:25:18 -04:00
parent 03b208cb9d
commit 78a11ad69b

View file

@ -755,6 +755,14 @@ impl AtPath {
} }
} }
/// Decide whether the named symbolic link exists in the test directory.
pub fn symlink_exists(&self, path: &str) -> bool {
match fs::symlink_metadata(&self.plus(path)) {
Ok(m) => m.file_type().is_symlink(),
Err(_) => false,
}
}
pub fn dir_exists(&self, path: &str) -> bool { pub fn dir_exists(&self, path: &str) -> bool {
match fs::metadata(&self.plus(path)) { match fs::metadata(&self.plus(path)) {
Ok(m) => m.is_dir(), Ok(m) => m.is_dir(),