summaryrefslogtreecommitdiff
path: root/subplotlib/src/steplibrary/files.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-02-27 12:32:28 +0000
committerLars Wirzenius <liw@liw.fi>2021-02-27 12:32:28 +0000
commitc7e899f2137391c5db62ff3bc28ed30df444d76a (patch)
treee3f0596ce7739f9446c3c3dd110368c183b3b8b8 /subplotlib/src/steplibrary/files.rs
parentc3a17851fd70a2462511ec6942627d0720cf6c5a (diff)
parente1881ecc58e84070e642bb764c721a28356163b9 (diff)
downloadsubplot-c7e899f2137391c5db62ff3bc28ed30df444d76a.tar.gz
Merge branch 'fix-167' into 'main'
Check for file vs. directory on path exists test See merge request larswirzenius/subplot!141
Diffstat (limited to 'subplotlib/src/steplibrary/files.rs')
-rw-r--r--subplotlib/src/steplibrary/files.rs7
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]