(&mut self)
| 118 | } |
| 119 | |
| 120 | fn mk(&mut self) { |
| 121 | if self.executable { |
| 122 | let mut path = self.path.clone().into_os_string(); |
| 123 | write!(path, "{}", env::consts::EXE_SUFFIX).unwrap(); |
| 124 | self.path = path.into(); |
| 125 | } |
| 126 | |
| 127 | self.dirname().mkdir_p(); |
| 128 | fs::write(&self.path, &self.body) |
| 129 | .unwrap_or_else(|e| panic!("could not create file {}: {}", self.path.display(), e)); |
| 130 | |
| 131 | #[cfg(unix)] |
| 132 | if self.executable { |
| 133 | use std::os::unix::fs::PermissionsExt; |
| 134 | |
| 135 | let mut perms = fs::metadata(&self.path).unwrap().permissions(); |
| 136 | let mode = perms.mode(); |
| 137 | perms.set_mode(mode | 0o111); |
| 138 | fs::set_permissions(&self.path, perms).unwrap(); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | fn dirname(&self) -> &Path { |
| 143 | self.path.parent().unwrap() |
no test coverage detected