Skip to content

Commit

Permalink
fix(linux): truncate or create file
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat616 committed Nov 24, 2024
1 parent 0b41543 commit f2277ad
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ impl AutoLaunch {
if !dir.exists() {
fs::create_dir(&dir)?;
}
fs::File::create(self.get_file())?.write(data.as_bytes())?;
let mut file = fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(self.get_file())?;
file.write_all(data.as_bytes())?;
Ok(())
}

Expand Down

0 comments on commit f2277ad

Please sign in to comment.