How are permissions applied to a file using set_mode?
rust
Solution
Use `OpenOptions`:
use std::fs;
use std::os::unix::OpenOptionsExt;
fn main() {
fs::OpenOptions::new()
.create(true)
.write(true)
.mode(0o770)
.open("somefile")
.unwrap();
}
Problem
If my understanding is correct, the following code should produce an executable file. However it doesn't; it gets created, but the permissions specified aren't applied. What am I doing wrong? ``` use std::fs; use std::os::unix::PermissionsExt; fn main() { fs::File::create("somefile").unwrap() .metadata().unwrap() .permissions() .set_mode(0o770); } ```