diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-01-03 06:16:07 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-01-03 06:16:07 +0000 |
commit | 0734368d45b349a6ab433c1d41f35a95ea58c9ec (patch) | |
tree | b69c6b84b9ce025d6f7afd92d734452757f4f365 /subplotlib/src/steplibrary/datadir.rs | |
parent | e8082fef03bd04042dad3fb2d0513587c54874ab (diff) | |
parent | b9de4d5e810d07b679ad9ab9e46d58e4c76213cc (diff) | |
download | subplot-0734368d45b349a6ab433c1d41f35a95ea58c9ec.tar.gz |
Merge branch 'more-rust-subplots' into 'main'
codegen: Refuse to generate code if the specified template is not present
Closes #259
See merge request subplot/subplot!242
Diffstat (limited to 'subplotlib/src/steplibrary/datadir.rs')
-rw-r--r-- | subplotlib/src/steplibrary/datadir.rs | 11 |
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)?; |