summaryrefslogtreecommitdiff
path: root/subplotlib/src/steplibrary/datadir.rs
diff options
context:
space:
mode:
Diffstat (limited to 'subplotlib/src/steplibrary/datadir.rs')
-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)?;