diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-02-27 10:44:52 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-02-27 10:44:52 +0000 |
commit | a7ad8ab28fb686df01183f9230d7a31601476776 (patch) | |
tree | c35e83eb2f6d84d126d8b4fc76ce5c7dc5137cd3 | |
parent | c3a17851fd70a2462511ec6942627d0720cf6c5a (diff) | |
download | subplot-a7ad8ab28fb686df01183f9230d7a31601476776.tar.gz |
subplotlib: path_exists - check path is a directory
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
-rw-r--r-- | subplotlib/src/steplibrary/files.rs | 7 |
1 files changed, 6 insertions, 1 deletions
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] |