#![allow(dead_code)]
use std::os::unix::fs::PermissionsExt;
use std::path::Path;
use std::process::Command;
pub fn copy_executable(from: &Path, to: &Path) {
let status = Command::new("cp")
.arg(from)
.arg(to)
.status()
.expect("running cp");
assert!(
status.success(),
"cp {} {} failed",
from.display(),
to.display()
);
std::fs::set_permissions(to, std::fs::Permissions::from_mode(0o755)).unwrap();
}
pub fn write_executable(path: &Path, body: &str) {
let mut source = path.as_os_str().to_owned();
source.push(".body");
std::fs::write(&source, body).unwrap();
copy_executable(Path::new(&source), path);
std::fs::remove_file(&source).unwrap();
}