14 lines
415 B
Rust
14 lines
415 B
Rust
use std::{fs::OpenOptions, io::Write, os::unix::fs::OpenOptionsExt};
|
|
|
|
pub fn write(path: &str, binary: &[u8]) {
|
|
let mut file = OpenOptions::new()
|
|
.create(true)
|
|
.write(true)
|
|
.truncate(true)
|
|
.mode(0o750)
|
|
.open(path)
|
|
.expect("Failed to create file");
|
|
file.write_all(binary).expect("Failed to write to file");
|
|
file.sync_all().expect("Failed to sync file");
|
|
}
|