summaryrefslogtreecommitdiff
path: root/subplotlib
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2021-05-30 21:36:26 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2021-12-27 14:27:44 +0000
commit689eb6665eca5bf2a86ddb3c40e25e438dd72d0a (patch)
tree74213cce22ac40675e357a43bab60bf9701cbea9 /subplotlib
parentdcc24d0c74a5af88253129e6e22023e8050cc72e (diff)
downloadsubplot-689eb6665eca5bf2a86ddb3c40e25e438dd72d0a.tar.gz
datadir: Add open_read() method to Datadir context
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'subplotlib')
-rw-r--r--subplotlib/src/steplibrary/datadir.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/subplotlib/src/steplibrary/datadir.rs b/subplotlib/src/steplibrary/datadir.rs
index 8aa6f00..88e6375 100644
--- a/subplotlib/src/steplibrary/datadir.rs
+++ b/subplotlib/src/steplibrary/datadir.rs
@@ -91,6 +91,17 @@ impl Datadir {
.open(full_path)?
}
+ /// Open a file for reading
+ #[throws(StepError)]
+ pub fn open_read<S: AsRef<Path>>(&self, subpath: S) -> File {
+ let full_path = self.canonicalise_filename(subpath)?;
+ OpenOptions::new()
+ .create(false)
+ .write(false)
+ .read(true)
+ .open(full_path)?
+ }
+
#[throws(StepError)]
pub fn create_dir_all<S: AsRef<Path>>(&self, subpath: S) {
let full_path = self.canonicalise_filename(subpath)?;