From a7ad8ab28fb686df01183f9230d7a31601476776 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 27 Feb 2021 10:44:52 +0000 Subject: subplotlib: path_exists - check path is a directory Signed-off-by: Daniel Silverstone --- subplotlib/src/steplibrary/files.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/subplotlib/src/steplibrary/files.rs b/subplotlib/src/steplibrary/files.rs index 8ba27cf..169111d 100644 --- a/subplotlib/src/steplibrary/files.rs +++ b/subplotlib/src/steplibrary/files.rs @@ -269,7 +269,12 @@ pub fn remove_directory(context: &Datadir, path: &str) { #[step] pub fn path_exists(context: &Datadir, path: &str) { let full_path = context.canonicalise_filename(path)?; - fs::metadata(full_path)?; + if !fs::metadata(&full_path)?.is_dir() { + throw!(format!( + "{} exists but is not a directory", + full_path.display() + )) + } } #[step] -- cgit v1.2.1