Skip to content

Commit

Permalink
Using OpenOptions instead of File for file creation
Browse files Browse the repository at this point in the history
  • Loading branch information
prsabahrami committed Sep 27, 2024
1 parent 596aa66 commit af545de
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/shell/src/commands/touch.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
ffi::OsString,
fs::{self, File},
fs::{self, OpenOptions},
path::{Path, PathBuf},
};

Expand Down Expand Up @@ -128,7 +128,7 @@ fn execute_touch(context: &mut ShellCommandContext) -> Result<()> {
continue;
}

File::create(path)
OpenOptions::new().create(true).truncate(false).write(true).open(path)
.into_diagnostic()
.map_err(|e| miette!("cannot touch {}: {}", path.display(), e))?;

Expand Down

0 comments on commit af545de

Please sign in to comment.