Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Fix forceful file creation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
fmckeogh committed Dec 16, 2022
1 parent 84f408b commit 9d45280
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion borealis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ fn create_file<P: AsRef<Path>>(path: P, force: bool) -> Result<BufWriter<File>>
File::options()
.write(true) // we want to write to the file
.create_new(!force) // fail if it already exists and force is true...
.truncate(true) // ...otherwise truncate it before writing
.create(true) // ...otherwise create...
.truncate(true) // ...and truncate before writing
.open(path.as_ref())
.map_err(ErrCtx::f(path))
.wrap_err(format!("Failed to write to file, force = {}", force))?,
Expand Down

0 comments on commit 9d45280

Please sign in to comment.